createCipheriv()
The node:crypto functions that encrypt (createCipheriv) and decrypt (createDecipheriv) data with a given algorithm, key and initialization vector.
In more detail
For AES-256-GCM, read the authentication tag with cipher.getAuthTag() after encrypting, and give it to decipher.setAuthTag() before decrypting. decipher.final() throws if the tag does not match, meaning the data was altered.
Related terms
- AES — The Advanced Encryption Standard: the widely used symmetric encryption algorithm standardised by NIST.
- Galois/Counter Mode — A mode of using a block cipher such as AES that both encrypts data and produces an authentication tag to detect any tampering.
- initialization vector — A random or unique value fed into encryption with the key, so the same plaintext encrypts differently each time.
- authentication tag — A short value, 16 bytes for AES-GCM, produced with the ciphertext that lets the receiver check nothing was changed.
Taught in
- Cryptographic Primitives: node:crypto & Ciphers — Node.js Internals & Backend Services