Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Javascript Articles
Page 220 of 534
Decipher.final() Method in Node.js
The decipher.final() is used to return a buffer or string containing the value of decipher object. It is one of the inbuilt method that is provided by the class Cipher within the crypto module. The decipher method cannot be used to decrypt data once the decipher.final method has been called. Calling the cipher.final method more than once will throw an error.Syntaxdecipher.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 – decipherFinal.js and copy the ...
Read Morecrypto.scrypt() Method in Node.js
The crypto.scrypt() method provides an asynchronous implementation for scrypt method. The scrypt can be defined as a password-based key derivation function that protects the system from the brute-force attacks and makes it unawarding. But the script function is expensive computationally as well as memory-wise.Syntaxcrypto.scrypt(password, salt, keylen, [options], [callback])ParametersThe above parameters are described as below −password – The password field for the scrypt required to decode entry. It can be a string, object, TypedArray, etc.salt – This value should be as unique as possible. This is mainly used for encrypting the data. The minimum suggested length of salt is 16 bytes.keylen – This parameter ...
Read Morecrypto.randomFillSync() Method in Node.js
The crypto.randomFillSync() method takes a buffer argument and returns the buffer by filling it with its encrypted value. As the name suggests, this will be a sync process.Syntaxcrypto.randomFillSync(buffer, [offset], [size])ParametersThe above parameters are described as below −buffer – This field contains the data content. Possible buffer types are: string, TypedArray, Buffer, ArrayBuffer, DataView. The size of the buffer cannot be greater than 2**31-1.offset – The value of the offset from where randomFill will start. Default value is 0.size – The size of the buffer after the offset, i.e., (buffer.length-offset). This value cannot be greater than 2**31-1.ExampleCreate a file with name – randomFillSync.js and ...
Read Morecrypto.randomFill() Method in Node.js
Both the crypto.randomFill() method and crypto.randomBytes() method are almost same. The only difference between the two is that – In randomFill() method the first argument is a buffer that will be filled. It also has a callback method that is called when an error is encountered only if the callback is configured.Syntaxcrypto.randomFill(buffer, [offset], [size], [callback])ParametersThe above parameters are described as below −buffer – This field contains the data content. Possible buffer types are: string, TypedArray, Buffer, ArrayBuffer, DataView. The size of the buffer cannot be greater than 2**31-1.offset – The value of the offset from where randomFill will start. Default value is ...
Read Morecrypto.getHashes() Method in Node.js
The crypto.getHashes() method will return an array that contains names of all the supported hash algorithms. The crypto package has a huge list of hash algorithms we can use. But the most used cipher algorithm is 'MD5 – Message-Digest Algorithm5 '.Syntaxcrypto.getHashes()ParametersSince it returns a list of all the hash algorithms. It does not need to have any input.ExampleCreate a file with name – getHashes.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 getHashes.jsgetHashes.js Live Demo// A node demo program for getting all hash algorithms ...
Read Morecrypto.getCurves() Method in Node.js
The crypto.getCurves() method will return an array that contains names of all the supported elliptic curves. The crypto package has a huge list of elliptic curves that can be used for creating Elliptic Curve Diffie-Hellman (ECDH) key exchange objectSyntaxcrypto.getCurves()ParametersSince it returns a list of all the elliptic curves. It does not need any arguments.ExampleCreate a file with name – curves.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 curves.jscurves.js Live Demo// A node demo program for getting all elliptic curves // Importing the crypto ...
Read Morecrypto.getCiphers() Method in Node.js
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 Live Demo// A node demo program for getting all cipher algorithms ...
Read Morecrypto.generateKeyPair() Method in Node.js
The crypto.generateKeyPair() can be used to generate a new asymmetric key pair of the specified type. Supported types for generating key pair are: 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, else the respective part of keyObject is returned.Syntaxcrypto.generateKeyPair(type, options, callback)ParametersThe above parameters are described as below −type – It holds the string type for which keys needs to be generated. Supported types are - RSA, DSA, EC, Ed25519, Ed448, X25519, X448 and DH.options – It can hold the following Parameters −modulusLength – ...
Read Morecrypto.createVerify() Method in Node.js
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 Morecrypto.createSign() Method in Node.js
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