Convert to binary and convert back to strings

Ganesan Rajagopal rganesan at myrealbox.com
Wed Feb 21 22:33:52 EST 2007


>>>>> "Harlin" == Harlin Seritt <harlinseritt at yahoo.com> writes:

> I tried doing this:

> text = 'supercalifragilisticexpialidocius'

> open('sambleb.conf', 'wb').write(text)

> Afterwards, I was able to successfully open the file with a text
> editor and it showed:
> 'supercalifragilisticexpialidocius'



> I am hoping to have it show up some weird un-readable text. And then
> of course be able to convert it right back to a string. Is this even
> possible?

Looks like you just want to obfuscate the string. How about this?

import base64
text = 'supercalifragilisticexpialidocius'
open('sambleb.conf', 'w').write(base64.encodestring(text))

print base64.decodestring(open('sambleb.conf', 'r').read())

Ganesan

-- 
Ganesan Rajagopal




More information about the Python-list mailing list