470,594 Members | 1,375 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,594 developers. It's quick & easy.

ezPyCrypto confusion

I am experimenting with ezPyCrypto
( http://www.freenet.org.nz/ezPyCrypto/ ).
Having difficulty making the key portable (ie put in a file). I don't
get an error message, I just recover a message string that is empty
instead of one that contains my message.

The code is below with a few extra print statements and comments that
hopefully make my problem clearer. Any help in getting it to work as
expected is appreciated. System is Mac OS 10.3 / Python 2.4.1 framework.

START PROGRAM--------------------------------------------

import ezPyCrypto

msg = 'Meeting delayed 30 hours'
print msg
print '--------------------'
k = ezPyCrypto.key(512)
cipher = k.encStringToAscii(msg)
print cipher
msg_back = k.decStringFromAscii(cipher)
print msg_back
print '--------------------'

# So far so good. encrypted and decrypted as expected.
# Now try to put the key in a file for transport on eg a USB drive.

key_as_string = k.exportKey()
print key_as_string
f = open('/Users/scott/pyprogs/the_key.txt', 'w')
f.write(key_as_string)
f.close()

# Now get string representation of k (the key object above) and use it
# to create a key object (ke) that should decode the original cipher

f=open('/Users/scott/pyprogs/the_key.txt', 'r')
x = f.read()
ke = ezPyCrypto.key(x)
print ke # Key object exists (good)
recovered_msg = ke.decString(cipher)
print type(recovered_msg) # A message string is returned (good)
print len(recovered_msg) # The string is EMPTY! (not good)
print recovered_msg # No message returned (not good)
f.close()

END PROGRAM-----------------------------------------------

RUN PROGRAM----------------------------------------------

scott$ python testezPyCrypto10.py
Meeting delayed 30 hours
--------------------
<StartPycryptoMessage>
5AAoVQNSU0FxAChjQ3J5cHRvLlB1YmxpY0tleS5SU0EKUlNBb2 JqCnEBb3ECfXEEKFUBZXEFTDY1
NTM3TApVAW5xBkw3MDg1MTU0ODQ3Nzg2Mzg1NzA3ODYxMzQ0ND cwNDQ3MDkzMTQ0NzkxNDIyMzAy
MDMwMjQxMTcxNjY2NzQ3MjQ3Njc0MTAxMTYwNjA4OTA0ODUxMz gxMDkyMjkwNjk5OTM3MTUwMTc0
Njc3MzI5NjY3NjQzOTUzNjQzMDQ4MTEwMTYwMTMyMDE3Nzk4MT cxOTYzOTkwMTY0MzIxTAp1YnRx
By5DAAFAAB0nHmncdr+reFXlH3sqlTD3sGzljukoy7bD0CqTIx 0G/wUBQikdDz/jUPG1lJeDpc3V
yW5alZnazsunbv9ck6RDAAFAAINJBPMc/j8FQznrDhrd5bIjsEIdYgL8Mhuyz4duDF2usmzKG+B0
zjuatNSSgYr6D3NsBnGc8kgcZFFsSldWql5DAAFAABuHpHTspB rEF4I9RWBMFdaw8bpAAaEx69w5
wAu5jx1PiPLHY+8VVWshIaIjKjTPnWuD1OmSIr17k0R5XTNoLa kIKBLNld6+SaoIb1AIRsYowggI
y/BY6VP0e70A
<EndPycryptoMessage>

Meeting delayed 30 hours
--------------------
<StartPycryptoKey>
KEkwMApOVeQoVQNSU0FxAChjQ3J5cHRvLlB1YmxpY0tleS5SU0 EKUlNBb2JqCnEBb3ECfXEEKFUB
ZXEFTDY1NTM3TApVAW5xBkw3MDg1MTU0ODQ3Nzg2Mzg1NzA3OD YxMzQ0NDcwNDQ3MDkzMTQ0Nzkx
NDIyMzAyMDMwMjQxMTcxNjY2NzQ3MjQ3Njc0MTAxMTYwNjA4OT A0ODUxMzgxMDkyMjkwNjk5OTM3
MTUwMTc0Njc3MzI5NjY3NjQzOTUzNjQzMDQ4MTEwMTYwMTMyMD E3Nzk4MTcxOTYzOTkwMTY0MzIx
TAp1YnRxBy5xAHRxAS4=
<EndPycryptoKey>

<ezPyCrypto.key instance at 0xc00f8>
<type 'str'>
0
Jul 19 '05 #1
0 1066

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by John Hunter | last post: by
reply views Thread by Bill Seitz | last post: by
3 posts views Thread by jlocc | last post: by
reply views Thread by i_have_control | last post: by
13 posts views Thread by Steve | last post: by
10 posts views Thread by joelagnel | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.