开发者

What is the best way to encode string by public-key in python

开发者 https://www.devze.com 2023-04-07 14:50 出处:网络
Is there any way to encode string by publi开发者_StackOverflowc-key? I found two packages, pycrypto and m2crypto.

Is there any way to encode string by publi开发者_StackOverflowc-key?

I found two packages, pycrypto and m2crypto. But I can not find how to use them.


To encode a string using public key:

#!/usr/bin/env python 
from M2Crypto import RSA, X509

x509 = X509.load_cert("recipient_cert.pem")
rsa = x509.get_pubkey().get_rsa()
print rsa.public_encrypt("your string to encrypt", RSA.pkcs1_oaep_padding)
0

精彩评论

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

关注公众号