[Tutor] flag to call methods on objects?
srilyk at gmail.com
Thu Jul 30 16:11:42 CEST 2009
On Thu, Jul 30, 2009 at 8:49 AM, prasad rao <prasadaraon50 at gmail.com> wrote:
> On 7/30/09, Rich Lovely <roadierich at googlemail.com> wrote:
>> 2009/7/30 prasad rao prasadaraon50 at gmail.com:
> >I'm sure there are modules available for PGP that are either part of
>> >the stdlib, or available from a quick google. PGP (or GPG) encryopts
> I never know there is an encryption module in stdlib.
> What is its name?
If you're only partially concerned (i.e. don't care about 'real' encryption)
you can use some of the string library encryptions.
mystr = str(mystr)
print "%s zip encoded: %s" % (mystr, mystr.encode('zip'))
print "%s rot13 encoded: %s" % (mystr, mystr.encode('rot13'))
print "%s hex encoded: %s" % (mystr, mystr.encode('hex'))
print "%s Base 64 encoded: %s" % (mystr, mystr.encode('base64'))
In : test_encode("The quick brown fox jumps over the lazy dogs")
The quick brown fox jumps over the lazy dogs zip encoded: xœ
The quick brown fox jumps over the lazy dogs rot13 encoded: Gur dhvpx oebja
sbk whzcf bire gur ynml qbtf
The quick brown fox jumps over the lazy dogs hex encoded:
The quick brown fox jumps over the lazy dogs Base 64 encoded:
So you could easily convert with encode and then reconvert with decode.
Another option would be a simple XOR of your data ( from here:
from itertools import izip, cycle
def xor_crypt_string(data, key):
return ''.join(chr(ord(x) ^ ord(y)) for (x,y) in izip(data, cycle(key)))
On the page provided someone also gave their code that can encrypt files.
Of course any of these methods presume you're just trying to keep the casual
snoop from getting access to your data. Anyone with time/inclination/tools
can go ahead and break most encryptions.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor