making files opposite from themselves (100% change)
Miguel Mendez
flynn at energyhq.es.eu.org
Mon Jul 5 14:01:26 PDT 2004
On Mon, 5 Jul 2004 13:55:00 -0700 (PDT)
Joe Schmoe <non_secure at 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 at energyhq.es.eu.org>
http://www.energyhq.es.eu.org
PGP Key: 0xDC8514F1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20040705/6ce0a0a3/attachment.bin
More information about the freebsd-questions
mailing list