public static rsaDecrypt(cipherText as String, privateKeyPem as String, padding as String = "OAEP", hashAlgorithm as String = "SHA-256", inputEncoding as String = "base64") as String throws CryptoException:
Decrypts RSA ciphertext with a private key.
| Parameter | Description |
|---|---|
cipherText | Encoded ciphertext. |
privateKeyPem | PEM-encoded private key. |
padding | RSA encryption padding. Defaults to OAEP. |
hashAlgorithm | Hash used by OAEP when applicable. |
inputEncoding | Ciphertext encoding: base64, base64url or hex. |
Decrypted UTF-8 text.
import klyn.cryptography
keys = RSAKeyPairGenerator().generateKeyPair()
encrypted = Cipher.rsaEncrypt("hello", keys.publicKeyPem)
print(Cipher.rsaDecrypt(encrypted, keys.privateKeyPem))