Front End Technology Articles

Page 50 of 652

Creating an Agent in Node.js

Mayank Agarwal
Mayank Agarwal
Updated on 11-Mar-2026 1K+ Views

You can use new Agent() method to create an instance of an agent in Node. The http.request() method uses the globalAgent from the 'http' module to create a custom http.Agent instance.Syntaxnew Agent({options})ParametersThe above function can accept the following Parameters −options – These options will contain the configurable options that could be set on an Agent while creation. Below are the fields/options the Agent can have −keepAlive – This method keeps the sockets around whether there are any outstanding requests or not, but keeps them for any future requests without actually re-establishing the TCP connection. One can use 'close' connection' to close this connection. ...

Read More

crypto.createHash() Method in Node.js

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

The crypto.createHash() method will create a hash object and then return it. THis hash object can be used for generating hash digests by using the given algorithm. The optional options are used for controlling the stream behaviour. For some hash functions like XOF and 'shake256' the output length is used for specifying the desired output length in bytes.Syntaxcrypto.createHash(algorithm, [options])ParametersThe above parameters are described as below −algorithm – This algorithm is used for generating the hash digests. Input type is string.options – These are optional parameters which can be used for controlling the stream behaviour.ExampleCreate a file with name – createHash.js and copy ...

Read More

crypto.createHmac() Method in Node.js

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

The crypto.createHmac() method will create a Hmac object and then return it. THis Hmac uses the passed algorithm and key. The optional options will be used for controlling the stream behaviour. The key defined will be the HMAC key used for generating cryptographic HMAC hash.Syntaxcrypto.createHmac(algorithm, key, [options])ParametersThe above parameters are described as below −algorithm – This algorithm is used for generating the Hmac objects. Input type is string.key – Hmac key used for generating the cryptographic Hmac hash.options – These are optional parameters which can be used for controlling the stream behaviour.encoding – String encoding to use.ExampleCreate a file with name – createHmac.js and ...

Read More

crypto.randomBytes() Method in Node.js

Mayank Agarwal
Mayank Agarwal
Updated on 11-Mar-2026 4K+ 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.pbkdf2() Method in Node.js

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

The crypto.pbkdf2(), also known as Password-Based Key Derivation function, provides an asynchronous implementation of the derivative function. A key is derived by using the Hmac digest of a specified algorithm from password, salt and iterationsSyntaxcrypto.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 the value as number.keylen – This is the requested byte length of ...

Read More

crypto.createECDH() Method in Node.js

Mayank Agarwal
Mayank Agarwal
Updated on 11-Mar-2026 518 Views

The crypto.createECDH() is used to create an elliptic curve also known as Elliptic Curve Diffie-Hellman i.e ECDH that uses a curve predefined by the input parameter curveName. You can use crypto.getCurves to get the list of all the available curve names. This method is part of the 'crypto' module.Syntaxcrypto.createECDH(curveName)ParametersThe above parameters are described as belowcurveName – It takes the input for the curve name. This curveName will deined the predefined curve for creating ECDH.ExampleCreate a file with name – createECDH.js and copy the below code snippet. After creating file, use the following command to run this code as shown in the ...

Read More

crypto.createCipheriv() Method in Node.js

Mayank Agarwal
Mayank Agarwal
Updated on 11-Mar-2026 5K+ 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

process.argv() Method in Node.js

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

The process.argv() method is used for returning all the command-line arguments that were passed when the Node.js process was being launched. The first element will always contains the same value as process.execPath.Syntaxprocess.argv()ParametersSince it returns all the command line arguments passed before the node.js process. It does not need any inputs from the user.ExampleCreate a file with name – argv.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 argv.jsargv.js// Node.js program to demonstrate the use of process.argv // Importing the process module const process ...

Read More

crypto.createDiffieHellmanGroup() Method in Node.js

Mayank Agarwal
Mayank Agarwal
Updated on 11-Mar-2026 182 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// crypto.createDiffieHellmanGroup Demo Example // Importing the crypto module const crypto = require('crypto'); // Defining the group name const name = 'modp1'; // Creating DiffieHellman group var ...

Read More

process.cpuUsage() Method in Node.js

Mayank Agarwal
Mayank Agarwal
Updated on 11-Mar-2026 1K+ Views

The process.argv() method is used for getting the user and its cpu usage for the current running process. The data is returned in an object with the properties user and system. The values obtained are in microseconds, i.e.10^-6 seconds. The values returned may be greater than the actual elapsed time if multiple cores are performing work for the running process.Syntaxprocess.cpuUsage([previousValue])ParametersThe method only accepts a single parameter which is defined below −previousValue – This is an optional parameter. This is the previous return value by calling the process.cpuUsage() method.ExampleCreate a file with name – cpuUsage.js and copy the below code snippet. After ...

Read More
Showing 491–500 of 6,517 articles
« Prev 1 48 49 50 51 52 652 Next »
Advertisements