(ciphertext: string)
| 33 | } |
| 34 | |
| 35 | export function decrypt(ciphertext: string): string { |
| 36 | const key = getKey(); |
| 37 | const buf = Buffer.from(ciphertext, ENCODING); |
| 38 | const iv = buf.subarray(0, IV_LENGTH); |
| 39 | const tag = buf.subarray(IV_LENGTH, IV_LENGTH + TAG_LENGTH); |
| 40 | const encrypted = buf.subarray(IV_LENGTH + TAG_LENGTH); |
| 41 | const decipher = createDecipheriv(ALGORITHM, key, iv); |
| 42 | decipher.setAuthTag(tag); |
| 43 | return decipher.update(encrypted) + decipher.final('utf8'); |
| 44 | } |
no test coverage detected