problem in encryption

jayshree jayshree06comp at gmail.com
Tue Sep 22 10:45:52 CEST 2009


On Sep 22, 1:44 pm, jayshree <jayshree06c... at gmail.com> wrote:
> 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 ?

the key looks like this :
-----BEGIN RSA PUBLIC KEY-----
mQGiBEpz7VIRBADAt9YpYfYHJeGA6d
+G261FHW1uA0YXltCWa7TL6JnIsuxvh9vImUoyMJd6
1xEW4TuROTxGcMMiDemQq6HfV9tLi7ptVBLf/8nUEFoGhxS
+DPJsy46WmlscKHRIEdIkTYhp
uAIMim0q5HWymEqqAfBLwJTOY9sR+nelh0NKepcCqwCgvenJ2R5UgmAh
+sOhIBrh3OahZEED
/2sRGHi4xRWKePFpttXfb2hry2/jURPae/wYfuI6Xw3k5EO593veGS7Zyjnt+7mVY1N5V/
ey
rfXaS3R6GsByG/eRVzRJGU2DSQvmF+q2NC6v2s4KSzr5CVKpn586SGUSg/
aKvXY3EIrpvAGP
rHum1wt6P9m9kr/4X8SdVhj7Jti6A/0TA8C2KYhOn/
hSYAMTmhisHan3g2Cm6yNzKeTiq6/0
ooG/
ffcY81zC6+Kw236VGy2bLrMLkboXPuecvaRfz14gJA9SGyInIGQcd78BrX8KZDUpF1Ek
KxQqL97YRMQevYV89uQADKT1rDBJPNZ+o9f59WT04tClphk/
quvMMuSVILQaamF5c2ggPGph
eXNocmVlQGdtYWlsLmNvbT6IZgQTEQIAJgUCSnPtUgIbAwUJAAFRgAYLCQgHAwIEFQIIAwQW
AgMBAh4BAheAAAoJEFjpOQ2vjFvzS0wAn3vf1A8npIY/DMIFFw0/
eGf0FNekAKCBJnub9GVu
9OUY0nISQf7uZZVyI7kBDQRKc+1SEAQAm7Pink6S5+kfHeUoJVldb
+VAlHdf7BdvKjVeiKAb
dFUa6vR9az+wn8V5asNy/
npEAYnHG2nVFpR8DTlN0eO35p78qXkuWkkpNocLIB3bFwkOCbff
P3yaCZp27Vq+9182bAR2Ah10T1KShjWTS/
wfRpSVECYUGUMSh4bJTnbDA2MAAwUEAIcRhF9N
OxAsOezkiZBm+tG4BgT0+uWchY7fItJdEqrdrROuCFqWkJLY2uTbhtZ5RMceFAW3s
+IYDHLL
PwM1O+ZojhvAkGwLyC4F
+6RCE62mscvDJQsdwS4L25CaG2Aw97HhY7+bG00TWqGLb9JibKie
X1Lk+W8Sde/4UK3Q8tpbiE8EGBECAA8FAkpz7VICGwwFCQABUYAACgkQWOk5Da+MW/
MAAgCg
tfUKLOsrFjmyFu7biv7ZwVfejaMAn1QXEJw6hpvte60WZrL0CpS60A6Q
-----END RSA PUBLIC KEY-----



More information about the Python-list mailing list