【发布时间】:2017-07-26 07:19:25
【问题描述】:
我正在将一项服务从 Python 2.7 迁移到 Python 3.5,该服务使用 RSA 加密/解密与另一个服务进行通信。
Python(v2.7) m2crypto(0.25.1)
key = M2Crypto.RSA.load_key(private_key)
digest = hashlib.sha1(bytes(cipher_text, encoding="UTF-8")).hexdigest()
signature = hexlify(key.private_encrypt(digest, M2Crypto.RSA.pkcs1_padding))
Python(v3.5) rsa(v3.4.2)
pri_key = rsa.PrivateKey.load_pkcs1(private_key)
signature = hexlify(rsa.sign(cipher_text.encode(), pri_key, "SHA-1"))
上述代码产生的签名不同。这些包有什么区别?
【问题讨论】:
标签: python-2.7 python-3.x rsa digital-signature m2crypto