Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Node.js Articles
Page 3 of 22
cipher.update() Method in Node.js
The cipher.update() method is used to update the cipher with data according to the specified encoding format. It is one of the built-in methods provided by the Cipher class within the crypto module. If an input encoding is specified, the data argument is a string; otherwise, the data argument is a buffer. Syntax cipher.update(data, [inputEncoding], [outputEncoding]) Parameters The parameters are described as follows: data – The data to be encrypted. Can be a string or buffer. ...
Read Morecrypto.createCipheriv() Method in Node.js
The crypto.createCipheriv() method creates and returns a cipher object using the specified algorithm, key, and initialization vector (IV). This method is essential for encrypting data in Node.js applications. Syntax crypto.createCipheriv(algorithm, key, iv, options) Parameters The parameters are described below: algorithm – The encryption algorithm to use (e.g., 'aes-256-cbc', 'aes-192-cbc') key – The raw key used by the algorithm. Can be string, ...
Read Morecrypto.createDiffieHellmanGroup() Method in Node.js
The crypto.createDiffieHellmanGroup() method creates a predefined Diffie-Hellman group using well-known parameters. This is an alias for crypto.getDiffieHellman() and provides a secure way to establish shared secrets between parties. Syntax crypto.createDiffieHellmanGroup(name) Parameters name − A string specifying the predefined group name (e.g., 'modp1', 'modp2', 'modp5', 'modp14', 'modp15', 'modp16', 'modp17', 'modp18'). Return Value Returns a DiffieHellman object that can generate keys and compute shared secrets. Example 1: Basic Usage with modp1 Create a file with name − diffieHellmanGroup.js and copy the below code snippet. After creating ...
Read Morecrypto.createECDH() Method in Node.js
The crypto.createECDH() method creates an Elliptic Curve Diffie-Hellman (ECDH) key exchange object using a predefined curve. ECDH is a cryptographic protocol that allows two parties to establish a shared secret over an insecure channel. Syntax crypto.createECDH(curveName) Parameters curveName - A string specifying the predefined elliptic curve to use. You can get available curves using crypto.getCurves(). Return Value Returns an ECDH object that can generate key pairs and compute shared secrets. Example 1: Basic ECDH Key Generation // Import the crypto module const crypto = require('crypto'); // ...
Read Morecrypto.createSign() Method in Node.js
The crypto.createSign() method creates and returns a Sign object that uses the specified algorithm for generating digital signatures. You can use crypto.getHashes() to get the names of all available digest algorithms. Sign instances can also be created using signature algorithms like 'RSA-SHA256' in some cases. Syntax crypto.createSign(algorithm, [options]) Parameters The parameters are described as follows: algorithm – The algorithm name to be used while creating the sign object/instance (e.g., 'SHA256', 'RSA-SHA256'). ...
Read Morecrypto.createVerify() Method in Node.js
The crypto.createVerify() method creates and returns a Verify object that uses the specified algorithm for digital signature verification. This method is essential for validating data integrity and authenticity in cryptographic operations. Syntax crypto.createVerify(algorithm, [options]) Parameters The parameters are described as below: algorithm – String that specifies the algorithm name to be used while creating the verify object/instance. You can use crypto.getHashes() to get available signing algorithms. ...
Read Morecrypto.generateKeyPair() Method in Node.js
The crypto.generateKeyPair() method generates a new asymmetric key pair of the specified type. Supported types include RSA, DSA, EC, Ed25519, Ed448, X25519, X448 and DH. The function behaves as if keyObject.export has been called on its result when a publicKeyEncoding or privateKeyEncoding is specified, otherwise the respective part of keyObject is returned. Syntax crypto.generateKeyPair(type, options, callback) Parameters The above parameters are described as below: type – It holds the string type for which keys need to be generated. Supported types are - RSA, DSA, EC, ...
Read Morecrypto.getCiphers() Method in Node.js
The crypto.getCiphers() method returns an array containing names of all the supported cipher algorithms in Node.js. This method is useful for discovering what encryption algorithms are available on your system. Syntax crypto.getCiphers() Parameters This method takes no parameters as it simply returns a list of all available cipher algorithms. Return Value Returns an array of strings, where each string is the name of a supported cipher algorithm. Basic Example Here's how to get all available cipher algorithms: // Importing the crypto module const crypto = require('crypto'); // ...
Read Morecrypto.getHashes() Method in Node.js
The crypto.getHashes() method returns an array containing the names of all supported hash algorithms available in Node.js. This is useful for discovering what hashing options are available in your current Node.js environment. Syntax crypto.getHashes() Parameters This method takes no parameters and returns an array of supported hash algorithm names. Return Value Returns an array of strings, where each string is the name of a supported hash algorithm. Example // Importing the crypto module const crypto = require('crypto'); // Get all supported hash algorithms const hashAlgorithms = crypto.getHashes(); ...
Read Morecrypto.privateDecrypt() Method in Node.js
The crypto.privateDecrypt() method is used for decrypting data that was previously encrypted using the corresponding public key with crypto.publicEncrypt(). This method is essential for implementing asymmetric encryption in Node.js applications. Syntax crypto.privateDecrypt(privateKey, buffer) Parameters The method accepts the following parameters: privateKey – Can be an Object, String, Buffer, or KeyObject containing: oaepHash – Hash function for OAEP padding and MGF1. Default: 'sha1' oaepLabel – Label for OAEP padding. ...
Read More