Node.js decipher.update() Method Last Updated : 03 Feb, 2023 Comments Improve Suggest changes Like Article Like Report The decipher.update() method is an inbuilt application programming interface of class Decipher within crypto module which is used to update the decipher with the data according to the given encoding format. Syntax: const decipher.update(data[, inputEncoding][, outputEncoding]) Parameters: This method takes the following parameter: data: It is used to update the decipher by new content.inputEncoding: Input encoding format.outputEncoding: Output encoding format. Return Value: This method does not return any value. Example 1: Filename: index.js JavaScript // Node.js program to demonstrate the // decipher.update() method // importing crypto module const crypto = require('crypto'); // Creating and initializing algorithm and password const algorithm = 'aes-192-cbc'; const password = 'Password used to generate key'; // Getting key for the decipher object const key = crypto.scryptSync(password, 'salt', 24); // Creating and initializing the static iv const iv = Buffer.alloc(16, 0); // Creating and initializing the decipher object const decipher = crypto.createDecipheriv(algorithm, key, iv); // Encrypted using same algorithm, key and iv. const encrypted = 'e5f79c5915c02171eec6b212d5520d44480993d7d622a7c4c2da32f6efda0ffa'; // Updating the data into decipher object let decrypted = decipher.update(encrypted, 'hex', 'utf8'); // Getting decrypted data decrypted += decipher.final('utf8'); // Display the result console.log("buffer :- " + decrypted); Output: buffer :- some clear text data Example 2: Filename: index.js JavaScript // Node.js program to demonstrate the // decipher.update() method // Importing crypto module const crypto = require('crypto'); // Creating and initializing algorithm and password const algorithm = 'aes-192-cbc'; const password = 'Password used to generate key'; // Getting key for cipher object crypto.scrypt(password, 'salt', 24, { N: 512 }, (err, key) => { if (err) throw err; // Creating and initializing the static iv const iv = Buffer.alloc(16, 0); // Creating and initializing the decipher object const decipher = crypto .createDecipheriv(algorithm, key, iv); // Encrypted using same algorithm, key and iv. const encrypted = 'e5f79c5915c02171eec6b212d5520d44480993d7d622a7c4c2da32f6efda0ffa'; // updating the data into decipher object const decrypted = decipher.update(encrypted, 'hex', 'utf8'); console.log("buffer :- " + decipher); }); Output: buffer :- [object Object] Run the index.js file using the following command: node index.js Reference: https://nodejs.org/dist/latest-v12.x/docs/api/crypto.html#crypto_decipher_update_data_inputencoding_outputencoding Comment More infoAdvertise with us R rohitprasad3 Follow Improve Article Tags : Web Technologies Node.js Node.js-Methods Node.js-crypto-module Similar Reads Node.js cipher.final() Method The cipher.final() method in Node.js is used to signal to the cipher object that the encryption or decryption process is complete. This method must be called after all data has been passed to the cipher object using the cipher.update() method. The cipher.final() method returns the remaining encrypte 2 min read Node.js cipher.update() Method The cipher.update() method is an inbuilt application programming interface of class Cipher within crypto module which is used to update the cipher with data according to the given encoding format. Syntax: const cipher.update(data[, inputEncoding][, outputEncoding]) Parameters: This method takes the 2 min read Node.js crypto.getCiphers() Method The crypto.getCiphers() method returns an array the names of all the supported cipher algorithms. Syntax: crypto.getCiphers() Parameters: This method doesn't accepts any parameters. Return Value: It returns the names of all the supported cipher algorithms. Below example illustrate the use of crypto. 2 min read Node.js crypto.createECDH() Method The crypto.createECDH() method is an inbuilt application programming interface of crypto module which is used to create an Elliptic Curve Diffie-Hellman i.e, (ECDH) key exchange object with the help of a predefined curve which is defined by the curveName string. Moreover you can use crypto.getCurves 2 min read Node.js crypto.createDecipheriv() Method The crypto.createDecipheriv() method is an inbuilt application programming interface of crypto module which is used to create a Decipher object, with the stated algorithm, key and initialization vector i.e, (iv). Syntax: crypto.createDecipheriv( algorithm, key, iv, options ) Parameters: This method 3 min read Node crypto.createCipheriv() Method The crypto.createCipheriv() method is an inbuilt application programming interface of the crypto module which is used to create a Cipher object, with the stated algorithm, key, and initialization vector (iv).Syntax: crypto.createCipheriv( algorithm, key, iv, options )Parameters: This method accepts 2 min read Node.js crypto.getDiffieHellman() Method The crypto.getDiffieHellman() method is used to create a predefined DiffieHellmanGroup key exchange object. Here, the favored groups are 'modp1', 'modp2', 'modp5', which are defined in RFC 2412 and 'modp14', 'modp15', 'modp16', 'modp17', 'modp18', defined in RFC 3526. Syntax: crypto.getDiffieHellman 2 min read Node.js crypto.pbkdf2() Method The crypto.pbkdf2() method gives an asynchronous Password-Based Key Derivation Function 2 i.e. (PBKDF2) implementation. Moreover, a particular HMAC digest algorithm which is defined by digest is implemented to derive a key of the required byte length (keylen) from the stated password, salt, and iter 2 min read Node crypto.createHash() Method The crypto.createHash() method is used to create a Hash object that can be used to create hash digests by using the stated algorithm. Syntax:crypto.createHash( algorithm, options )Parameters: This method accepts two parameters as mentioned above and described below:algorithm: It is dependent on the 2 min read Node.js crypto.createHmac() Method The crypto.createHmac() method is used to create an Hmac object that uses the stated 'algorithm' and 'key'.Syntax:crypto.createHmac( algorithm, key, options )Parameters: This method accepts three parameters as mentioned above and described below:algorithm: It is dependent on the accessible algorithm 2 min read Like