Convert to binary and convert back to strings

Hendrik van Rooyen mail at microcorp.co.za
Thu Feb 22 01:18:07 EST 2007


 "Harlin Seritt" <harlinseritt at yahoo.com> wrote:


> Hi...
> 
> I would like to take a string like 'supercalifragilisticexpialidocius'
> and write it to a file in binary forms -- this way a user cannot read
> the string in case they were try to open in something like ascii text
> editor. I'd also like to be able to read the binary formed data back
> into string format so that it shows the original value. Is there any
> way to do this in Python?
> 

I would xor each char in it with 'U' as a mild form of obfuscation...

Look at the array module to get things you can xor, or use ord() on
each byte, and char()

Note that char(ord('U')) is 'U', and ord('U') is the equivalent of 0x55,
or five sixteens plus five - 85.

If its ascii just writing it out as binary is useless for what you want to do.

This will invert every alternate bit, producing apparent gibberish.

HTH - Hendrik




More information about the Python-list mailing list