Web Development Articles

Page 273 of 801

crypto.createHmac() Method in Node.js

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 3K+ Views

The crypto.createHmac() method creates and returns an HMAC (Hash-based Message Authentication Code) object in Node.js. This method uses a specified algorithm and secret key to generate cryptographic hashes for data integrity and authentication purposes. Syntax crypto.createHmac(algorithm, key, [options]) Parameters algorithm – The hashing algorithm to use (e.g., 'sha256', 'sha1', 'md5'). Input type is string. key – The secret key used for generating the cryptographic HMAC hash. Can be a string, Buffer, TypedArray, or DataView. options – Optional parameters for controlling stream ...

Read More

crypto.pbkdf2() Method in Node.js

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 2K+ Views

The crypto.pbkdf2() method in Node.js implements the Password-Based Key Derivation Function 2 (PBKDF2) algorithm. It derives a cryptographic key from a password using a salt and multiple iterations to enhance security against brute-force attacks. Syntax crypto.pbkdf2(password, salt, iterations, keylen, digest, callback) Parameters The parameters are described as follows: password – The password string used for key derivation. Accepts string, Buffer, TypedArray, or DataView. ...

Read More

agent.maxFreeSockets Property in Node.js

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 575 Views

The agent.maxFreeSockets property defines the maximum number of sockets that can be kept open in the free state for connection reuse. This is part of Node.js HTTP agent configuration and helps optimize HTTP connection pooling. Syntax agent.maxFreeSockets = number Parameters number – Specifies the maximum number of sockets that can remain open in the free state. Default value is 256. Understanding Free Sockets Free sockets are HTTP connections that have completed their current request but remain open for potential reuse. This improves performance by avoiding the overhead of establishing new ...

Read More

async.queue() Method in Node.js

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 5K+ Views

The async module provides different functionalities to work with asynchronous JavaScript in a Node.js application. The async.queue() method creates a queue object for concurrent processing of tasks, allowing multiple items to be processed simultaneously based on a specified concurrency limit. Installation First, initialize your Node.js project and install the async module: npm init npm install --save async Then import the async module in your program: const async = require('async'); Syntax async.queue(worker, concurrency) Parameters worker – A function that processes each ...

Read More

cipher.final() Method in Node.js

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 855 Views

The cipher.final() method in Node.js returns the remaining encrypted data after all input has been processed through cipher.update(). This method completes the encryption process and can only be called once per cipher instance. Syntax cipher.final([outputEncoding]) Parameters outputEncoding – Optional string parameter specifying the output format. Common values include 'hex', 'base64', 'latin1'. If not provided, returns a Buffer. Return Value Returns a Buffer containing the final encrypted data, or a string if outputEncoding is specified. Example 1: Basic Usage with Different Encodings // Importing ...

Read More

cipher.update() Method in Node.js

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 727 Views

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 More

crypto.createCipheriv() Method in Node.js

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 5K+ Views

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 More

crypto.createDiffieHellmanGroup() Method in Node.js

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 198 Views

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 More

crypto.createECDH() Method in Node.js

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 540 Views

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 More

crypto.createSign() Method in Node.js

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 404 Views

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 More
Showing 2721–2730 of 8,010 articles
« Prev 1 271 272 273 274 275 801 Next »
Advertisements