On Mon, 5 Jul 2004 13:55:00 -0700 (PDT)
Joe Schmoe <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]>
        http://www.energyhq.es.eu.org
        PGP Key: 0xDC8514F1

Attachment: pgpNScRmyLOLI.pgp
Description: PGP signature

Reply via email to