problem in encryption

jayshree jayshree06comp at gmail.com
Tue Sep 22 04:44:03 EDT 2009


hello ,
The community members,

Using following code  :

fileHandle = open ('jay1key.py','wb')
#fileHandle = open ('jay1key.pem',rb).read()
print fileHandle.write (data) #data variable is contains the key
fileHandle.close()


otp = 'jyshri69'


pub_key = M2Crypto.RSA.load_pub_key('jay1key.py')

encrypted = pub_key.public_encrypt(otp, M2Crypto.RSA.pkcs1_padding)
print "encrypted text is =   "
print "-----------------------"
print encrypted

the above code gives me following error :
None
Traceback (most recent call last):
  File "RetEnc.py", line 71, in ?
    pub_key = M2Crypto.RSA.load_pub_key('jay1key.py')
  File "/usr/lib/python2.4/site-packages/M2Crypto/RSA.py", line 344,
in load_pub_key
    return load_pub_key_bio(bio)
  File "/usr/lib/python2.4/site-packages/M2Crypto/RSA.py", line 360,
in load_pub_key_bio
    rsa_error()
  File "/usr/lib/python2.4/site-packages/M2Crypto/RSA.py", line 240,
in rsa_error
    raise RSAError, m2.err_reason_error_string(m2.err_get_error())
M2Crypto.RSA.RSAError: no start line


not getting how to resolve it ?



More information about the Python-list mailing list