Convert to binary and convert back to strings

Grant Edwards grante at visi.com
Wed Feb 21 21:26:08 EST 2007


On 2007-02-22, Harlin Seritt <harlinseritt at yahoo.com> wrote:

>> Try opening your file in the 'wb' mode.

> 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'

Of course it did.

> 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?

Sure.  That's what is called "encryption".  There are a bunch
of encryption libraries for Python.

http://www.amk.ca/python/code/crypto
http://www.freenet.org.nz/ezPyCrypto
http://www.example-code.com/python/encryption.asp
http://www.chilkatsoft.com/python-encryption.asp

-- 
Grant Edwards                   grante             Yow!  Two with FLUFFO,
                                  at               hold th' BEETS...side of
                               visi.com            SOYETTES!



More information about the Python-list mailing list