rsa 解密
(cipher_password, key, base64encode=True)
| 63 | |
| 64 | |
| 65 | def rsa_decrypt(cipher_password, key, base64encode=True): |
| 66 | """rsa 解密""" |
| 67 | if base64encode: |
| 68 | cipher_password = b64decode(cipher_password) |
| 69 | key = RSA.importKey(key) |
| 70 | cipher = PKCS1_OAEP.new(key) |
| 71 | modBits = Crypto.Util.number.size(key.n) |
| 72 | k = Crypto.Util.number.ceil_div(modBits, 8) |
| 73 | message = b"" |
| 74 | for i in range(0, len(cipher_password), k): |
| 75 | message += cipher.decrypt(cipher_password[i:i+k]) |
| 76 | return message |