/** * Checks if an object is an instance of Crypto. * @param {any} object - The object to check. * @returns {boolean} Returns true if the object is an instance of Crypto, false otherwise. */ export declare function isCrypto(object: any): object is Crypto; /** * Interface representing the set of parameters to create an instance of the Crypto class. * @interface CryptoOptions * @property {string} password - The password used for key derivation. * @property {string} salt - The salt used for key derivation. * @property {string} [algorithm='sha512'] - The hash algorithm to use for key derivation. * @property {number} [iterations=1000] - The number of iterations to use for key derivation. * @property {number} [keyLength=32] - The length of the derived key in bytes. * @property {number|Buffer} [iv] - The initialization vector for the AES encryption. */ export interface CryptoOptions { password: string; salt: string; algorithm?: string; iterations?: number; keyLength?: number; iv?: number | Buffer; } /** * Class representing a cryptographic utility for encrypting and decrypting text. * @class * @param {string|CryptoOptions} passwordOrOptions - The password used for key derivation or an options object. * @param {string} salt - The salt used for key derivation. * @param {string} [algorithm='sha512'] - The hash algorithm to use for key derivation. * @param {number} [iterations=1000] - The number of iterations to use for key derivation. * @param {number} [keyLength=32] - The length of the derived key in bytes. * @param {number|Buffer} [iv] - The initialization vector for the AES encryption. */ export declare class Crypto { private iv; private key; constructor(password: string, salt: string, algorithm?: string, iterations?: number, keyLength?: number, iv?: number | Buffer); constructor(options: CryptoOptions); private convertNumberToIV; /** * Encrypt a text string. * Uses the IV supplied at construction time (fixed or random-at-construct). * The IV is **not** embedded in the output — both sides must use the same IV. * For persistent storage use {@link encryptStorable} instead. * * @param {string} text - The plain text to encrypt. * @returns {string} The encrypted text as a hex string. */ encrypt(text: string): string; /** * Decrypt an encrypted text string produced by {@link encrypt}. * Uses the IV supplied at construction time. * * @param {string} text - The encrypted text as a hex string. * @returns {string} The decrypted plain text. */ decrypt(text: string): string; /** * Encrypts text and prepends a fresh random IV to the output. * * Use this method when the ciphertext will be stored (database, file, etc.) * and retrieved later in a different process instance. A new random IV is * generated for every call, so repeated encryptions of the same plaintext * produce different ciphertexts — no IV reuse across records. * * Output format: `hex( IV[16 bytes] || ciphertext[N bytes] )` * * The construction-time IV is **not** used by this method. * * @param {string} text - The plain text to encrypt. * @returns {string} Hex string containing the prepended IV and ciphertext. * @see {@link decryptStorable} */ encryptStorable(text: string): string; /** * Decrypts a value produced by {@link encryptStorable}. * * Extracts the first 16 bytes as the IV, then decrypts the remainder. * The construction-time IV is **not** used by this method. * * @param {string} text - Hex string `IV[16 bytes] || ciphertext` from {@link encryptStorable}. * @returns {string} The decrypted plain text. * @throws {RangeError} When the input is shorter than 16 bytes (32 hex chars). * @see {@link encryptStorable} */ decryptStorable(text: string): string; /** * Returns a UUID ver.4 string. * @returns {string} UUID ver.4 string. */ static getUUID(): string; } export default Crypto;