Web Development Articles

Page 54 of 801

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

crypto.createSign() Method in Node.js

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

The crypto.createSign() will create and return a sign object tha uses the passed algorithm in the parameter. One can use, crypto.getHashes() to get the names of all the available digest algorithms. You can create a Sign instance by using the name of the signature algorithms such as 'RHA-SHA256' only in some of the cases, instead of a digest algorithm.Syntaxcrypto.createSign(algorithm, [options])ParametersThe above parameters are described as below −algorithm – It takes the input for the algorithm name to be used while creating the sign object/instance.options – This is an optional parameter that can be used for controlling the stream behaviour.ExampleCreate a file ...

Read More

crypto.createVerify() Method in Node.js

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

The crypto.createVerify() will create and return a verify object that uses the passed algorithm in the parameter. One can use, crypto.getHashes() to get the names of all the available signing algorithms. You can create a Verify instance by using the name of the signature algorithms such as 'RHA-SHA256' only in some of the cases, instead of a digest algorithm.Syntaxcrypto.createVerify(algorithm, [options])ParametersThe above parameters are described as below −algorithm – It takes the input for the algorithm name to be used while creating the verify object/instance.options – This is an optional parameter that can be used for controlling the stream behaviour.ExampleCreate a file with ...

Read More

crypto.getCiphers() Method in Node.js

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

The crypto.getCiphers() method will return an array that contains names of all the supported cipher algorithms. The crypto package has a huge list of cipher algorithms we can use. But the most used cipher algorithm is 'AES – Advanced Encryption Standard'.Syntaxcrypto.getCiphers()ParametersSince it returns a list of all the cipher algorithms. It does not need to have any input.ExampleCreate a file with name – getCipher.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 getCipher.jsgetCipher.js// A node demo program for getting all cipher algorithms // ...

Read More
Showing 531–540 of 8,006 articles
« Prev 1 52 53 54 55 56 801 Next »
Advertisements