def rsa_decrypt(encrypted_data, pem, password=None):
from cryptography.hazmat.backends import default_backend<EOL>from cryptography.hazmat.primitives import serialization<EOL>from cryptography.hazmat.primitives import hashes<EOL>from cryptography.hazmat.primitives.asymmetric import padding<EOL>encrypted_data = to_binary(encrypted_data)<EOL>pem = to_binary(pem)<EOL>private_key = serialization.load_pem_private_key(pem, password, backend=default_backend())<EOL>data = private_key.decrypt(<EOL>encrypted_data,<EOL>padding=padding.OAEP(<EOL>mgf=padding.MGF1(hashes.SHA1()),<EOL>algorithm=hashes.SHA1(),<EOL>label=None,<EOL>)<EOL>)<EOL>return data<EOL>
rsa 解密
:param encrypted_data: 待解密 bytes
:param pem: RSA private key 内容/binary
:param password: RSA private key pass phrase
:return: 解密后的 binary