Node.js Crypto Module
Crypto
The node:crypto module provides cryptographic functionality that includes a set of wrappers for OpenSSL's hash, HMAC, cipher, decipher, sign, and verify functions.
The node:crypto module provides cryptographic functionality that includes a set of wrappers for OpenSSL's hash, HMAC, cipher, decipher, sign, and verify functions.
It is possible for Node.js to be built without including support for the node:crypto module. In such cases, attempting to import from crypto or calling require('node:crypto') will result in an error being thrown.
SPKAC is a Certificate Signing Request mechanism originally implemented by Netscape and was specified formally as part of HTML5's keygen element.
<keygen> is deprecated since HTML 5.2 and new projects should not use this element anymore.
Exports a cryptographic challenge associated with a certificate, often used in secure communication protocols to verify ownership of a certificate or domain.
It allows to extract the public key material, which can then be used for cryptographic operations like encryption, signature verification, or sharing securely.
It is used to verify and decode a SPKAC (Signed Public Key and Challenge) structure.
SPKAC is typically generated as part of the key generation and certificate signing request process in browsers.
Extends: <stream.Transform>
Instances of the Cipher class are used to encrypt data.
It is used to finalize the encryption process.
After encrypting data in chunks using a Cipher object, you call cipher.final() to generate the final encrypted data block.
It is used with authenticated encryption modes, such as GCM (Galois/Counter Mode), to retrieve the authentication tag generated during the encryption process.
When using an authenticated encryption mode (GCM, CCM, OCB, and chacha20-poly1305 are currently supported), the method sets the value used for the additional authenticated data (AAD) input parameter.
When using block encryption algorithms, the Cipher class will automatically add padding to the input data to the appropriate block size.
To disable the default padding call cipher.setAutoPadding(false).
Updates the cipher with data.
If the inputEncoding argument is given, the data argument is a string using the specified encoding.
Extends: <stream.Transform>
Instances of the Decipher class are used to decrypt data.
Once the decipher.final() method has been called, the Decipher object can no longer be used to decrypt data.
Attempts to call decipher.final() more than once will result in an error being thrown.
When using an authenticated encryption mode (GCM, CCM, OCB, and chacha20-poly1305 are currently supported), the decipher.setAAD() method sets the value used for the additional authenticated data (AAD) input parameter.