RSA_public_decrypt() 的 Python3 OpenSSL 绑定(bind)

标签 python cryptography openssl rsa

python 3.4 中是否有任何 openssl 绑定(bind)绑定(bind)了 libopenssl 中的函数 RSA_public_decrypt() 允许我们使用公钥解密内容?出于某种原因,我需要在项目中执行此操作。

最佳答案

我遇到了同样的问题,我发现这个解决方案有点老套(注意 *.hazmat.* 导入)

def do_decrypt_cryptography(message, private_key):
    from cryptography.hazmat.primitives import hashes
    from cryptography.hazmat.primitives.asymmetric import padding
    return private_key.decrypt(message,
                               padding.OAEP(mgf=padding.MGF1(algorithm=hashes.SHA1()),
                                            algorithm=hashes.SHA1(),
                                            label=None))

关于RSA_public_decrypt() 的 Python3 OpenSSL 绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22732384/

相关文章:

openssl - 证书中的 "-----BEGIN TRUSTED CERTIFICATE-----"是什么意思?

python - 按天分组一堆文件

python - 将动态python对象转换为json

java - (BouncyCasSTLe 错误 : min may not be greater than max ) implementation of El-Gamal algorithm using java

cryptography - 私钥长度字节

python - 使用 OpenSSL 静态编译 Python 3.6

python - pip3 无法获取 URL https ://pypi. org/simple/pip/:确认 ssl 证书时出现问题

python - Pandas 根据条件将列添加到具有另一行值的数据框

python - 是PyVISA安装失败吗?或者,我做错了什么吗?

cryptography - 使用 "node-forge"、 "exponent"和 "modulus"在 "maxdigits"中生成 key 对