decryptRsaOaep
Decrypt an RSA-OAEP ciphertext with the matching private key.
ts
function decryptRsaOaep(
privateKey: CryptoKey,
ciphertext: Uint8Array,
_: unknown,
): Promise<DecryptRsaOaepResult>Parameters
privateKey:CryptoKeyciphertext:Uint8Array_:unknown
See also
decryptRsaOaepOrThrowfor the throwing variant
Examples
ts
const decrypted = await decryptRsaOaep(keys.privateKey, ciphertext);
if (!decrypted.ok) {
// decrypted.code: 'invalid_key' | 'decryption_failed'
throw new Error(decrypted.message);
}
const plaintext = decrypted.value;