加密常见的填充模式有三种:RSA_PKCS1_PADDING,RSA_PKCS1_OAEP_PADDING,RSA_NO_PADDING,还有Java常用的加密算法RSA/ECB/OAEPWithSHA256AndMGF1Padding;其中前三种都是比较常见的,这里主要演示最后一种。
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import padding
from cryptography.hazmat.primitives import hashes
from base64 import b64encode