Node.js Articles

Page 2 of 22

crypto.createDiffieHellman() Method in Node.js

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

The crypto.createDiffieHellman() method in Node.js creates a Diffie-Hellman key exchange object using a specified prime value and an optional generator. This method enables secure key exchange between two parties over an insecure channel. Syntax crypto.createDiffieHellman(prime, [primeEncoding], [generator], [generatorEncoding]) Parameters prime – The prime number used for the Diffie-Hellman exchange. Can be a number (bit length) or Buffer/string containing the prime value. primeEncoding ...

Read More

process.argv() Method in Node.js

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

The process.argv property returns an array containing command-line arguments passed when the Node.js process was launched. The first element is the path to the Node.js executable, and the second is the path to the JavaScript file being executed. Syntax process.argv Parameters process.argv is a property, not a method, so it doesn't take any parameters. It automatically captures all command-line arguments passed to the Node.js process. Basic Usage Example Create a file named argv.js and run it using the command node argv.js: // Node.js program to demonstrate the use of process.argv ...

Read More

crypto.createHash() Method in Node.js

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

The crypto.createHash() method creates a hash object that can generate hash digests using cryptographic algorithms like SHA-256, MD5, or SHA-512. It's commonly used for password hashing, data integrity verification, and digital signatures. Syntax crypto.createHash(algorithm, [options]) Parameters algorithm – The hashing algorithm to use (string). Common values: 'sha256', 'md5', 'sha512', 'sha1' options – Optional parameters for controlling stream behavior and output length for certain algorithms Return Value Returns a Hash object that can be used to generate hash digests by chaining update() and digest() methods. Example 1: Basic Hash Generation ...

Read More

process.chdir() Method in Node.js

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

The process.chdir() method changes the current working directory of the Node.js process. It throws an exception if the operation fails (such as when the specified directory doesn't exist) but returns no value on success. Syntax process.chdir(directory) Parameters directory – A string containing the path to the directory you want to change to. Return Value This method returns undefined on success and throws an error if the directory change fails. Example 1: Successful Directory Change // Node.js program to demonstrate process.chdir() const process = ...

Read More

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

urlObject.auth() Method in Node.js

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

The auth property of a parsed URL object contains the username and password portion of a URL, also known as userInfo. The username and password are separated by a colon (:). Syntax urlObject.auth Parameters The auth property is read-only and does not require any input parameters. It returns the authentication credentials from the parsed URL. Example 1: Basic Authentication Create a file named auth.js and run it using node auth.js: // Importing the URL module const url = require('url'); var adr = 'https://username=hello:password=tutorialspoint@www.tutorialspoint.com/'; // Parsing the above URL ...

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 571 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 854 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
Showing 11–20 of 212 articles
« Prev 1 2 3 4 5 22 Next »
Advertisements