Skip to content

decryptRsaOaep

Decrypt an RSA-OAEP ciphertext with the matching private key.

ts
function decryptRsaOaep(
	privateKey: CryptoKey,
	ciphertext: Uint8Array,
	_: unknown,
): Promise<DecryptRsaOaepResult>

Parameters

  • privateKey: CryptoKey
  • ciphertext: Uint8Array
  • _: unknown

See also

  • decryptRsaOaepOrThrow for 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;

Released under the MIT License.