Date: Mon, 5 Jul 2004 22:59:55 +0200 From: Miguel Mendez <flynn@energyhq.es.eu.org> To: Joe Schmoe <non_secure@yahoo.com> Cc: freebsd-questions@freebsd.org Subject: Re: making files opposite from themselves (100% change) 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>
next in thread | previous in thread | raw e-mail | index | archive | help
--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 <non_secure@yahoo.com> 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 <flynn@energyhq.es.eu.org> 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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040705225955.240ea437.flynn>