UNPKG

es-next-tools

Version:

A comprehensive utility library for JavaScript and TypeScript that provides a wide range of functions for common programming tasks, including mathematical operations, date manipulations, array and object handling, string utilities, and more.

28 lines (27 loc) 1.23 kB
/** * Encrypts a text using AES-256-GCM algorithm. * @param {string} text - The text to encrypt. * @param {string} key - The encryption key. * @returns {{ encrypted: string; iv: string; authTag: string }} An object containing the encrypted text, initialization vector (iv), and authentication tag (authTag). * @example * // Returns an object with encrypted text, iv, and authTag * encrypt("Hello, World!", "my-secret-key"); */ export declare function encrypt(text: string, key: string): { encrypted: string; iv: string; authTag: string; }; /** * Decrypts an encrypted text using AES-256-GCM algorithm. * @param {string} encrypted - The encrypted text. * @param {string} key - The encryption key. * @param {string} iv - The initialization vector used during encryption. * @param {string} authTag - The authentication tag generated during encryption. * @returns {string} The decrypted text. * @example * // Returns the decrypted text "Hello, World!" * const encrypted = encrypt("Hello, World!", "my-secret-key"); * decrypt(encrypted.encrypted, "my-secret-key", encrypted.iv, encrypted.authTag); */ export declare function decrypt(encrypted: string, key: string, iv: string, authTag: string): string;