Optionalalgorithm: stringOptionaliterations: numberOptionalkeyLength: numberOptionaliv: number | BufferEncrypt 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 encryptStorable instead.
The plain text to encrypt.
The encrypted text as a hex string.
Decrypt an encrypted text string produced by encrypt. Uses the IV supplied at construction time.
The encrypted text as a hex string.
The decrypted plain text.
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.
The plain text to encrypt.
Hex string containing the prepended IV and ciphertext.
Decrypts a value produced by encryptStorable.
Extracts the first 16 bytes as the IV, then decrypts the remainder. The construction-time IV is not used by this method.
Hex string IV[16 bytes] || ciphertext from encryptStorable.
The decrypted plain text.
StaticgetReturns a UUID ver.4 string.
UUID ver.4 string.
Class representing a cryptographic utility for encrypting and decrypting text.
Param: passwordOrOptions
The password used for key derivation or an options object.
Param: salt
The salt used for key derivation.
Param: algorithm
The hash algorithm to use for key derivation.
Param: iterations
The number of iterations to use for key derivation.
Param: keyLength
The length of the derived key in bytes.
Param: iv
The initialization vector for the AES encryption.