跳到主要内容

aesDecrypt()

function aesDecrypt(
cipherText,
keyString,
ivString
): Promise<string>;

Defined in: packages/utils/src/crypto/aesDecrypt.ts:18

使用 AES-GCM 算法解密数据

Parameters​

ParameterTypeDescription
cipherTextstringBase64 编码的密文字符串
keyStringstringBase64 编码的 AES 密钥字符串
ivStringstringBase64 编码的初始化向量字符串

Returns​

Promise<string>

解密后的明文字符串

Throws​

当解密失败时抛出错误

Example​

const plaintext = await aesDecrypt('encryptedData', 'keyInBase64', 'ivInBase64');
console.log(plaintext); // 输出解密后的明文
**注意:** 使用 Web Crypto API 进行 AES-GCM 解密
**注意:** 密钥长度为 256 位
**注意:** 所有输入参数都应为有效的 Base64 字符串