ezPyCrypto confusion

S

scott

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>
5AAoVQNSU0FxAChjQ3J5cHRvLlB1YmxpY0tleS5SU0EKUlNBb2JqCnEBb3ECfXEEKFUBZXEFTDY1
NTM3TApVAW5xBkw3MDg1MTU0ODQ3Nzg2Mzg1NzA3ODYxMzQ0NDcwNDQ3MDkzMTQ0NzkxNDIyMzAy
MDMwMjQxMTcxNjY2NzQ3MjQ3Njc0MTAxMTYwNjA4OTA0ODUxMzgxMDkyMjkwNjk5OTM3MTUwMTc0
Njc3MzI5NjY3NjQzOTUzNjQzMDQ4MTEwMTYwMTMyMDE3Nzk4MTcxOTYzOTkwMTY0MzIxTAp1YnRx
By5DAAFAAB0nHmncdr+reFXlH3sqlTD3sGzljukoy7bD0CqTIx0G/wUBQikdDz/jUPG1lJeDpc3V
yW5alZnazsunbv9ck6RDAAFAAINJBPMc/j8FQznrDhrd5bIjsEIdYgL8Mhuyz4duDF2usmzKG+B0
zjuatNSSgYr6D3NsBnGc8kgcZFFsSldWql5DAAFAABuHpHTspBrEF4I9RWBMFdaw8bpAAaEx69w5
wAu5jx1PiPLHY+8VVWshIaIjKjTPnWuD1OmSIr17k0R5XTNoLakIKBLNld6+SaoIb1AIRsYowggI
y/BY6VP0e70A
<EndPycryptoMessage>

Meeting delayed 30 hours
--------------------
<StartPycryptoKey>
KEkwMApOVeQoVQNSU0FxAChjQ3J5cHRvLlB1YmxpY0tleS5SU0EKUlNBb2JqCnEBb3ECfXEEKFUB
ZXEFTDY1NTM3TApVAW5xBkw3MDg1MTU0ODQ3Nzg2Mzg1NzA3ODYxMzQ0NDcwNDQ3MDkzMTQ0Nzkx
NDIyMzAyMDMwMjQxMTcxNjY2NzQ3MjQ3Njc0MTAxMTYwNjA4OTA0ODUxMzgxMDkyMjkwNjk5OTM3
MTUwMTc0Njc3MzI5NjY3NjQzOTUzNjQzMDQ4MTEwMTYwMTMyMDE3Nzk4MTcxOTYzOTkwMTY0MzIx
TAp1YnRxBy5xAHRxAS4=
<EndPycryptoKey>

<ezPyCrypto.key instance at 0xc00f8>
<type 'str'>
0
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Output confusion 2
Tasks 1
ChatBot 4
email parsing 1
Getting error from previously working code 0
generate and send mail with python: tutorial 8
sqlite3 import performance 1
trouble quitting PyQt4 App 0

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top