Encrypts a single media chunk with a deterministic IV derived from the file key, recording ID, and chunk index.
Uses direct WebCrypto crypto.subtle.encrypt with the deterministic nonce so that the decrypting side can recover the IV without storing it separately.
crypto.subtle.encrypt
The 32-byte per-file key.
The chunk data to encrypt.
Recording/file identifier for domain separation.
Sequential chunk index (0-based).
Object with encrypted ciphertext (includes GCM tag) and IV.
const { encrypted, iv } = await encryptMediaChunk(fileKey, chunkData, 'rec-42', 0);// store encrypted + iv; IV is recoverable via deriveChunkNonce Copy
const { encrypted, iv } = await encryptMediaChunk(fileKey, chunkData, 'rec-42', 0);// store encrypted + iv; IV is recoverable via deriveChunkNonce
Encrypts a single media chunk with a deterministic IV derived from the file key, recording ID, and chunk index.
Uses direct WebCrypto
crypto.subtle.encryptwith the deterministic nonce so that the decrypting side can recover the IV without storing it separately.