开发者

Python RSA library?

开发者 https://www.devze.com 2023-02-10 18:03 出处:网络
from Crypto.PublicKey import RSA private = RSA.generate(1024, os.urandom) Now how do I export or import keys? Ev开发者_StackOverflowerything is there except these 2 functions!
from Crypto.PublicKey import RSA
private = RSA.generate(1024, os.urandom)

Now how do I export or import keys? Ev开发者_StackOverflowerything is there except these 2 functions!

private.exportKey()
private.publickey.exportKey()

Preferably in --armor format :)

Any ideas?


Thanks all. Turned out that Ubuntu installs an old version of PyCrypto and I had to fetch 2.3 from their website.


If you are using PyCryto, then I see that PyCryto 2.2 has that functionality. Otherwise you will find the patch here useful.


Crypto.PublicKey's exportKey is within module rsa, under _RSAobj class. You can look at the documentation here. You can export the public or private key with 'DER' (PKCS#1) or 'PEM' (RFC1421) format.

0

精彩评论

暂无评论...
验证码 换一张
取 消