@socialgouv/streaming-file-encryption
Version:
Streaming file encryption for Node.js using AES-256-GCM, HKDF and HMAC.
26 lines (21 loc) • 976 B
TypeScript
import * as stream from 'stream';
type CipherAlgorithm = 'aes-256-gcm' | 'chacha20-poly1305';
/**
* Generate a 64 byte hex-encoded main secret string.
*
* @returns a hex-encoded string representation (128 hex characters)
*/
declare function generateSerializedMainSecret(): string;
/**
* Decode a serialized main secret to a Buffer.
*
* @param serialized hex-encoded string of 64 bytes (128 hex characters)
* @returns
*/
declare function decodeMainSecret(serialized: string): Buffer;
declare module 'node:stream' {
function compose(...streams: (Stream | Iterable<Buffer | string> | AsyncIterable<Buffer | string> | Function)[]): Duplex;
}
declare function encryptFile(mainSecret: Buffer | Uint8Array, context: string, algorithm?: CipherAlgorithm): stream.Duplex;
declare function decryptFile(mainSecret: Buffer | Uint8Array, context: string): stream.Duplex;
export { CipherAlgorithm, decodeMainSecret, decryptFile, encryptFile, generateSerializedMainSecret };