繁体   English   中英

可以使用openssl而不是Python RSA和Base64算法吗?

[英]Can use openssl instead of Python RSA and Base64 algorithms?

可以使用openssl命令实现Python RSA和Base64算法的等效功能吗?

例如,RSA公钥和要加密的密码是已知的。 Python算法是

ciphertext = base64.b64encode(PKCS1_v1_5.new(pubkey).encrypt(password.encode('utf-8')))

假设密码为123456,公钥为pubkey.pem。 以下openssl命令是否等同于Python算法?

echo 123456 | openssl rsautl -encrypt -pubin -inkey pubkey.pem -out ciphertext.txt | openssl enc -e -base64 -in ciphertext.txt -out r.txt

r.txt的结果相当于Python算法的密文?

是的,它应该是,当且仅当您的密码当然是“123456”时。

当然,PKCS#1 v1.5填充执行的随机化意味着密文总是不同的。

测试:使用Python中的反向操作和私钥解密密文。 为了更加确定,也使用openssl解密。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM