(buffer: Uint8Array, key: AesKey)
| 24 | } |
| 25 | |
| 26 | export function decrypt(buffer: Uint8Array, key: AesKey): string { |
| 27 | const nonce = buffer.subarray(0, NONCE_SIZE); |
| 28 | const tag = buffer.subarray(buffer.length - TAG_SIZE); |
| 29 | const ciphertext = buffer.subarray(NONCE_SIZE, buffer.length - TAG_SIZE); |
| 30 | const decipher = createDecipheriv('aes-256-gcm', key, nonce); |
| 31 | decipher.setAuthTag(tag); |
| 32 | const plaintext = decipher.update(ciphertext); |
| 33 | decipher.final(); |
| 34 | return plaintext.toString('utf8'); |
| 35 | } |
no outgoing calls
no test coverage detected