(data: string, key64: string)
| 52 | } |
| 53 | |
| 54 | export async function decryptAESGCMString(data: string, key64: string): Promise<string | null> { |
| 55 | try { |
| 56 | const key = await importKey(key64, 'decrypt'); |
| 57 | const { iv, ciphertext } = split(decodeBase64(data)); |
| 58 | const plaintext = await crypto.subtle.decrypt( |
| 59 | { name: ALGO, iv: iv as BufferSource }, |
| 60 | key, |
| 61 | ciphertext as BufferSource, |
| 62 | ); |
| 63 | return new TextDecoder().decode(plaintext); |
| 64 | } catch { |
| 65 | return null; |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | export async function encryptAESGCM(data: Uint8Array, key64: string): Promise<Uint8Array> { |
| 70 | // Mirror aes.ts: the existing AES path round-trips bytes-as-UTF-8-strings. |
no test coverage detected