klyn.cryptography.Cipher.rsaDecrypt
method

    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:

Description

Decrypts RSA ciphertext with a private key.

Parameters

- 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`.

Returns

Decrypted UTF-8 text.

Throws

- CryptoException when decryption fails. ```klyn import klyn.cryptography keys = RSAKeyPairGenerator().generateKeyPair() encrypted = Cipher.rsaEncrypt("hello", keys.publicKeyPem) print(Cipher.rsaDecrypt(encrypted, keys.privateKeyPem)) ```