From owner-freebsd-questions@FreeBSD.ORG Mon Jul 5 21:01:26 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 03B3216A4CF for ; Mon, 5 Jul 2004 21:01:26 +0000 (GMT) Received: from mindfields.energyhq.es.eu.org (73.Red-213-97-200.pooles.rima-tde.net [213.97.200.73]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6FD0443D1F for ; Mon, 5 Jul 2004 21:01:12 +0000 (GMT) (envelope-from flynn@energyhq.es.eu.org) Received: from scienide (scienide.energyhq.es.eu.org [192.168.100.1]) by mindfields.energyhq.es.eu.org (Postfix) with SMTP id 918843585D; Mon, 5 Jul 2004 23:00:41 +0200 (CEST) Date: Mon, 5 Jul 2004 22:59:55 +0200 From: Miguel Mendez To: Joe Schmoe Message-Id: <20040705225955.240ea437.flynn@energyhq.es.eu.org> In-Reply-To: <20040705205500.30396.qmail@web53306.mail.yahoo.com> References: <20040705205500.30396.qmail@web53306.mail.yahoo.com> X-Mailer: Sylpheed version 0.9.11-gtk2-20040613 (GTK+ 2.4.3; i386-portbld-freebsd4.8) Mime-Version: 1.0 Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg="pgp-sha1"; boundary="Signature=_Mon__5_Jul_2004_22_59_55_+0200_FkDAiJ/QNtyooByP" cc: freebsd-questions@freebsd.org Subject: Re: making files opposite from themselves (100% change) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Jul 2004 21:01:26 -0000 --Signature=_Mon__5_Jul_2004_22_59_55_+0200_FkDAiJ/QNtyooByP Content-Type: text/plain; charset=US-ASCII Content-Disposition: inline Content-Transfer-Encoding: 7bit On Mon, 5 Jul 2004 13:55:00 -0700 (PDT) Joe Schmoe wrote: Hi, > So the question is, how do I take a given file and > make it 100% different from itself (but maintain its > size and place on disk) ? I could just output > /dev/zero to it, but that would leave unchanged all > the bits that were aleady zero. > > So how do I flip the bits of an entire file ? > Further, is there a good command line that will flip > the bits of some percentage of the file ? The xor operation of a byte/word/dword with itself does that. You could setup a buffer of the desired % of bytes you want to change, read the bytes, xor them (^ in C) with itself and write back. It's trivial in C/Perl/python/whathaveyou. Or you could fetch some random data from /dev/urandom if you prefer. -- Miguel Mendez http://www.energyhq.es.eu.org PGP Key: 0xDC8514F1 --Signature=_Mon__5_Jul_2004_22_59_55_+0200_FkDAiJ/QNtyooByP Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (FreeBSD) iD8DBQFA6cFOnLctrNyFFPERAnX+AJ9EJpBLTujuoQpb+IfgPiefvTioIgCfdyKb oYfChmW3t8hZkjGBleBWP6U= =ZiPW -----END PGP SIGNATURE----- --Signature=_Mon__5_Jul_2004_22_59_55_+0200_FkDAiJ/QNtyooByP--