
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 10483 Articles for Web Development

2K+ Views
The crypto.publicEncrypt() is used for encrypting the given data in buffer parameter by using a public key passed in the parameter. The data returned can be decrypted using the corresponding private key.Syntaxcrypto.publicEncrypt(key, buffer)ParametersThe above parameters are described as below −key – It can contain the below 5 types of data of the following type – Object, String, Buffer or KeyObject.key – This field contains the PEM encoded public or private key. It can be of type string, buffer or keyObject.oaepHash – This field contains the hash function to be used for OAEP padding and MGF1. Default value is: 'sha1'.oaepLabel – This field contains the ... Read More

690 Views
The crypto.publicDecrypt() is used for decrypting the given data in buffer with public key. This buffer was encrypted by using the corresponding private key i.e. crypto.privateEncrypt() method.Syntaxcrypto.publicDecrypt(key, buffer)ParametersThe above parameters are described as below −key – It can contain the below 5 types of data of the following type – Object, String, Buffer or KeyObject.passphrase - This is an optional passphrase for the private key.padding – This is an optional value defined in crypto.constants.encoding – This is the type of encoding that needs to be used when buffer, key, oaepLabel or passphrase value are strings.buffer – This field contains the data content to be ... Read More

711 Views
The crypto.privateEncrypt() is used for encrypting the given data content by using the given private key parameter passed in the function.Syntaxcrypto.privateEncrypt(privateKey, buffer)ParametersThe above parameters are described as below −privateKey – It can contain following data types – Object, String, Buffer or KeyObject.key – This key is a 'PEM' encoded private key. The key can be of type string, buffer or KeyObject.passphrase – This is an optional passphrase value for the private key.padding – This is an optional value defined in crypto.constants.buffer – This field contains the data content to be decrypted. Possible buffer types are: string, TypedArray, Buffer, ArrayBuffer, DataView.ExampleCreate a file with name – ... Read More

2K+ Views
The crypto.privateDecrypt() is used for decrypting the given data content by using a private key passed in the parameter that was previously encrypted using the corresponding public key with crypto.publicEncrypt() method.Syntaxcrypto.privateDecrypt(privateKey, buffer)ParametersThe above parameters are described as below −key – It can contain the below 5 types of data of the following type – Object, String, Buffer or KeyObject.oaepHash – This field contains the hash function to be used for OAEP padding and MGF1. Default value is: 'sha1'.oaepLabel – This field contains the value for OAEP padding. No lable is used if not specified.padding – This is an optional value defined in crypto.constants.buffer – This ... Read More

215 Views
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 More

173 Views
The crypto.createDiffieHellmanGroup() is used for creating a pre-determined DiffieHellmanGroup key exchange object. Some of the supported DiffieHellmanGroups are: modp1, modp2, modp5, modp 14, modp16, modp17 etc. The benefit of using this method is that the parties don't need to generate or exchange a group modulus thus saving processing time.Syntaxcrypto.getDiffieHelmmanGroup(groupName)ParametersThe above parameters are described as below −groupName – It takes the input for the group name. The input is of type 'string'.ExampleCreate a file with name – getdiffieHellman.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 ... Read More

311 Views
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 More

264 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 Live Demo// A node demo program for getting all cipher algorithms ... Read More

2K+ Views
The crypto.generateKeyPairSync() can be used to generate a new asymmetric key pair of the specified type in a sync flow. 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. The suggested type for public key is 'spki' and for private key it is 'pkcs8'.Syntaxcrypto.generateKeyPairSync(type, options)ParametersThe above parameters are described as below −type – It holds the string type for which keys needs to be generated. Supported types ... Read More

2K+ Views
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 More