Javascript Articles

Page 175 of 534

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 849 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 724 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 193 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 532 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 399 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

crypto.createVerify() Method in Node.js

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

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 More

crypto.generateKeyPair() Method in Node.js

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

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 More

crypto.getCiphers() Method in Node.js

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

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 More
Showing 1741–1750 of 5,340 articles
« Prev 1 173 174 175 176 177 534 Next »
Advertisements