python function for retrieving key and encryption
jayshree06comp at gmail.com
Mon Jul 27 08:47:00 CEST 2009
On Jul 23, 5:48 pm, Piet van Oostrum <p... at cs.uu.nl> wrote:
> >>>>> jayshree <jayshree06c... at gmail.com> (j) wrote:
> >j> On Jul 21, 8:59 pm, Piet van Oostrum <p... at cs.uu.nl> wrote:
> >>> The recipient_public_key.pem file is the public key of the recipient
> >>> which means the person that is going to receive the encrypted message.
> >>> You should get it from the recipient him/herself or from some key store
> >>> where s/he has deposited it.
> >j> error coming like - IOError: [Errno 2] No such file or directory:
> >j> 'recipient_public_key.pem'
> >j> Is this not the inbuilt file.
> >j> How should i create such type of file.
> You don't create it. See above. If you understand what is is you know
> why it can't be builtin. If you don't understand it is better if you
> first learn about OpenSSL, otherwise you run the risk to make serious
> If you are just experimenting to create a message for yourself then you
> have to create the public key because you are then the recipient
> yourself. That has been answered onhttp://stackoverflow.com/questions/1169798/m2crypto-package
> Piet van Oostrum <p... at cs.uu.nl>
> URL:http://pietvanoostrum.com[PGP 8DAE142BE17999C4]
> Private email: p... at vanoostrum.org
from M2Crypto import RSA,SSL
pk = open('my_key.public.pem', 'rb').read()
rsa = M2Crypto.RSA.load_pub_key(pk) #return a M2Crypto.RSA.RSA_pub
plaintext = 4545479545655576767767686688782344
msg = rsa.public_encrypt(plaintext,RSA.pkcs1_padding)
This is code i am refering.
The Problem is coming with .pem file.
I also asked this questions at http://stackoverflow.com/questions/1176864/problem-with-the-pem-file-closed
which has not been answered .
please help me out....
More information about the Python-list