(password: string, envelope: Uint8Array)
| 1107 | } |
| 1108 | |
| 1109 | async function decryptMessage(password: string, envelope: Uint8Array): Promise<string> { |
| 1110 | const salt = envelope.slice(0, 16); |
| 1111 | const iv = envelope.slice(16, 28); |
| 1112 | const ciphertext = envelope.slice(28, envelope.length - 16); |
| 1113 | const authTag = envelope.slice(envelope.length - 16); |
| 1114 | |
| 1115 | const key = await deriveKey(password, salt); |
| 1116 | |
| 1117 | return Stream.text( |
| 1118 | Stream.pull(Stream.from(ciphertext), createAes256GcmDecryptTransform(key, { iv, authTag })) |
| 1119 | ); |
| 1120 | } |
| 1121 | |
| 1122 | const password = 'my-secret'; |
| 1123 | const message = 'Complete encrypted message using Stream.pull()!'; |
no test coverage detected