(
crypto: ISodium,
key: Uint8Array,
cipher: { header: string; chunks: string[] }
)
| 55 | } |
| 56 | |
| 57 | export async function streamingDecrypt( |
| 58 | crypto: ISodium, |
| 59 | key: Uint8Array, |
| 60 | cipher: { header: string; chunks: string[] } |
| 61 | ) { |
| 62 | await crypto.initialize(); |
| 63 | const state = crypto.crypto_secretstream_xchacha20poly1305_init_pull( |
| 64 | crypto.from_base64(cipher.header), |
| 65 | key |
| 66 | ); |
| 67 | return [ |
| 68 | crypto.crypto_secretstream_xchacha20poly1305_pull( |
| 69 | state, |
| 70 | crypto.from_base64(cipher.chunks[0]), |
| 71 | null, |
| 72 | "text" |
| 73 | ), |
| 74 | crypto.crypto_secretstream_xchacha20poly1305_pull( |
| 75 | state, |
| 76 | crypto.from_base64(cipher.chunks[1]), |
| 77 | null, |
| 78 | "text" |
| 79 | ), |
| 80 | crypto.crypto_secretstream_xchacha20poly1305_pull( |
| 81 | state, |
| 82 | crypto.from_base64(cipher.chunks[2]), |
| 83 | null, |
| 84 | "text" |
| 85 | ) |
| 86 | ]; |
| 87 | } |
| 88 | |
| 89 | export async function decrypt( |
| 90 | crypto: ISodium, |
no test coverage detected