Found 6683 Articles for Javascript

crypto.createDiffieHellmanGroup() Method in Node.js

Mayank Agarwal
Updated on 20-May-2021 12:20:24

79 Views

The crypto.createDiffieHellmanGroup() is used for creating the DiffieHellmanGroup. This method can also be referred as an alias for crypto.getDiffieHellman.Syntaxcrypto.createDiffieHelmmanGroup(name)ParametersThe above parameters are described as below −name – It takes the input for the group name. The input is of type 'string'.ExampleCreate a file with name – diffieHellmanGroup.js and copy the below code snippet. After creating file, use the following command to run this code as shown in the example below −node diffieHellmanGroup.jsdiffieHellmanGroup.js Live Demo// crypto.createDiffieHellmanGroup Demo Example // Importing the crypto module const crypto = require('crypto'); // Defining the group name const name = 'modp1'; // Creating DiffieHellman group ... Read More

crypto.createDecipheriv() Method in Node.js

Mayank Agarwal
Updated on 20-May-2021 12:20:01

2K+ Views

The crypto.createCipheriv() is a programming interface from the 'crypto' module. It will create and return the Decipher object as per the given algorithm, key, iv and options passed in the function.Syntaxcrypto.createDecipheriv(algorithm, key, iv, [options])ParametersThe above parameters are described as below −algorithm – It takes the input for the algorithm that would be used to create the cipher. Some possible values are: aes192, aes256, etc.key – It takes input for the raw key that is used by the algorithm and iv. Possible values can be of type: string, buffer, TypedArray or DataView. It can optionally be a type object of secret type.iv – ... Read More

crypto.createCipheriv() Method in Node.js

Mayank Agarwal
Updated on 20-May-2021 12:19:36

4K+ Views

The crypto.createCipheriv() method will first create and then return the cipher object as per the algorithm passed for the given key and authorization factor (iv).Syntaxcrypto.createCipheriv(algorithm, key, iv, options)ParametersThe above parameters are described as below −algorithm – It takes the input for the algorithm that would be used to create the cipher. Some possible values are: aes192, aes256, etc.key – It takes input for the raw key that is used by the algorithm and iv. Possible values can be of type: string, buffer, TypedArray or DataView. It can optionally be a type object of secret type.iv – Also known as the initialization vector. This ... Read More

cipher.update() Method in Node.js

Mayank Agarwal
Updated on 20-May-2021 12:09:13

492 Views

The cipher.update() is used to update the cipher with the receivd data according to the given encoding format. It is one of the inbuilt method that is provided by the class Cipher within the crypto module. If an input encoding is specified, the data argument is a string, else the data argument is a bufferSyntaxcipher.update(data, [inputEncoding], [outputEncoding])ParametersThe above parameters are described as below −data – It takes the data as an input that is passed to update the cipher content.inputEncoding – It takes the input encoding as a parameter. Possible input values are hex, base64, etc.outputEncoding – It takes the output encoding as ... Read More

cipher.final() Method in Node.js

Mayank Agarwal
Updated on 20-May-2021 12:08:48

531 Views

The cipher.final() is used to return a buffer or string containing the value of cipher object. It is one of the inbuilt method that is provided by the class Cipher within the crypto module. If an output encoding is specified, a String is returned. If an output encoding is not specified a buffer is returned. Calling the cipher.final method more than once will throw an error.Syntaxcipher.final([outputEncoding])ParametersThe above parameters are described as below −outputEncoding – It takes the output encoding as a parameter. The input type for this parameter is string. Possible input values are hex, base64, etc.ExampleCreate a file with name ... Read More

async.queue() Method in Node.js

Mayank Agarwal
Updated on 20-May-2021 12:04:02

3K+ Views

The async module provides different functionalities to work with asynchronous JavaScript in a nodejs application. The async.queue() method returns a queue that is further used for concurrent processing of processes i.e. multiple processing of items at a time/instant.Installing and Using async.queue()Step 1 − Run the following command to initialize the node package manager.npm initStep 2 − Installing the async module using the following command.npm install --save asyncStep 3 − Importing the async module using the below statement in your programs .const async = require('async')Syntaxasync.queue('function', 'concurrency value')ParametersThe above parameters are described as below −function – This parameter defines the function that will ... Read More

agent.maxSockets Property in Node.js

Mayank Agarwal
Updated on 20-May-2021 12:00:29

384 Views

The agent.maxSockets property defines the number of sockets that can be concurrently opened by the agent for each origin. By default, this value is set to Infinity. This is also a part of the 'http' module.Syntaxagent.maxSockets: numberParametersThe above function can accept the following Parameters −number – This defines the number of concurrent sockets an agent can have. Its default value is set to Infinity.ExampleCreate a file with name – maxSockets.js and copy the below code snippet. After creating file, use the following command to run this code as shown in the example below:node maxSockets.jsmaxSockets.js// agent.maxSockets method Demo example // Importing ... Read More

agent.maxFreeSockets Property in Node.js

Mayank Agarwal
Updated on 20-May-2021 11:59:46

356 Views

The agent.maxFreeSockets property defines the number of sockets that are left open while in the free state. This is a part of the 'http' module interface.Syntaxagent.maxFreeSockets : numberParametersThe above function can accept the following parameters −number – This defines the number of sockets that can be kept open in the free state. Its default value is set to 256.ExampleCreate a file with name – maxFreeSockets.js and copy the below code snippet. After creating file, use the following command to run this code as shown in the example below −node maxFreeSockets.jsmaxFreeSockets.js −// agent.maxFreeSockets method Demo example // Importing the http & ... Read More

crypto.randomBytes() Method in Node.js

Mayank Agarwal
Updated on 20-May-2021 11:59:03

3K+ Views

The crypto.randomBytes() generates cyprtographically strong pseudo-random data. This method will not be completed until there is sufficient entropy in the bytes created. But even after this it does not takes more than a few milliseconds. This method basically creates a few random bytes which are further used.Syntaxcrypto.randomBytes(size, [callback])ParametersThe above parameters are described as below −size – This argument defines the number of bytes to be generated. Size must not be greater than 2**31 – 1.callback – The callback is called if any error occurs in the method.ExampleCreate a file with name – randomBytes.js and copy the below code snippet. After creating file, ... Read More

crypto.pbkdf2Sync() Method in Node.js

Mayank Agarwal
Updated on 20-May-2021 11:57:51

856 Views

The crypto.pbkdf2Sync(), also known as Password-Based Key Derivation function 2, provides a synchronous implementation of the derivative function. A key is derived by using the Hmac digest of a specified algorithm from password, salt and iterations. This will create the key in a sync process.Syntaxcrypto.createHmac(algorithm, key, [options])ParametersThe above parameters are described as below −password – Password defined for getting key of the requested byte length. Possible values are of type string, DataView, Buffer, etc.salt – Similar to password for getting the key. Possible values are of type string, DataView, Buffer, etc.iterations – Getting the desired key of requested byte length. It accepts ... Read More

Advertisements