How to convert M2Crypto.RSA.RSA to string

Usman Ajmal uzmanajmal at gmail.com
Wed Sep 17 05:05:41 EDT 2008


Actually my problem is a little different. I have a .pem format file which
contain my public and private key both and i want to get only the public key
from that file as a string.

I already have done that by just parsing the said file but if there is some
direct way i will b glad to know.

@marco i don't have the string at all. Infact i want the string
@Toivonen i tried as_pem but it gives me some private key after doing some
thing with the file i pass to it as argument which is even not the private
key i have in my file. Also if i set cipher=None, even then its result is
same

Thanks by the way marco and Toivonen for trying to help :)

On Mon, Sep 15, 2008 at 1:06 PM, Marco Bizzarri <marco.bizzarri at gmail.com>wrote:

> On Mon, Sep 15, 2008 at 8:23 AM, Usman Ajmal <uzmanajmal at gmail.com> wrote:
> > Hi,
> >
> > I have a M2Crypto.RSA.RSA instance that contain my public-key. I want
> that
> > key as string. Is there any way to convert the said instance into string?
>
>
> In case you want to write the pub-key to a file, you can use save_pub_key
>
>    def save_pub_key(self, file):
>        """
>        Save the public key to a file in PEM format.
>
>        @type file: string
>        @param file: Name of file to save key to.
>        """
>
> Regards
> Marco
> --
> Marco Bizzarri
> http://notenotturne.blogspot.com/
> http://iliveinpisa.blogspot.com/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080917/5e08606e/attachment-0001.html>


More information about the Python-list mailing list