Node.js crypto.setEngine() Function Last Updated : 26 May, 2022 Comments Improve Suggest changes Like Article Like Report Node.js is a cross-platform, open-source back-end JavaScript runtime environment that uses the V8 engine to execute JavaScript code outside of a web browser. Node.js allows developers to utilize JavaScript to create command-line tools and server-side scripting, which involves running scripts on the server before sending the page to the user's browser. Cryptographic functionality is provided via the crypto module, which includes wrappers for OpenSSL's hash, HMAC, cypher, decode, sign, and verify methods. The crypto.setEngine() function load and configure the engine for some or all OpenSSL functions, selected by the flags. Syntax: crypto.setEngine(engine[, flags]) Parameters: engine: This is either an id or a path to the shared library of the engine.flags: The flags are a bit field taking one of or a mix of the flags. It is used to select the class of functions. The default value is ENGINE_METHOD_ALL. Example 1: Create a node.js project alongside a file named index.js and write the following code. JavaScript const crypto = require("crypto"); crypto.setEngine("dynamic"); const secret = 'geeksforgeeks'; const hash = crypto .createHmac('sha256', secret) .update('I am a geek') .digest('hex'); console.log(hash); Steps to run the application: You can run the code by typing the following line of code: node index.js Output:  Example 2: Create a node.js project alongside a file named index.js and write the following code. JavaScript const crypto = require("crypto"); crypto.setEngine("dynamic", crypto.constants.ENGINE_METHOD_DH); const dh = crypto.createDiffieHellman(512); dh.generateKeys() const publicKey = dh.getPublicKey(); console.log(publicKey); Steps to run the application: You can run the code by typing the following line of code: node index.js Note: This limits the engine usage to only Diffie Hellman. Output:  Reference: https://nodejs.org/dist/latest-v12.x/docs/api/crypto.html#crypto_crypto_setengine_engine_flags Comment More infoAdvertise with us Next Article Node.js crypto.setEngine() Function A aayushmohansinha Follow Improve Article Tags : Web Technologies Node.js Node.js-Methods Node.js-crypto-module Similar Reads Node.js crypto.sign() Function Cryptography is the process of converting plain text into unreadable which is hashed from text and vice-versa and the crypto.sign() is used to create signature of data. Syntax: crypto.sign(algorithm, data, key)Parameters: This function accepts the following parameters: algorithm: It is a string-ty 3 min read Node.js crypto.setFips() Function The crypto.setFips() method is an inbuilt application programming interface of class Crypto within the crypto module which is used to enable the FIPS compliant crypto provider in a FIPS-enabled Node.js build. Syntax: const crypto.setFips(bool)Parameters: This API takes the Boolean value as a paramet 2 min read Node.js crypto.verify() Function The crypto.verify()  is a method of the inbuilt module of node.js crypto that is used to verify the signature of data that is hashed using different kinds of hashing functions Like SHA256 algorithm etc. Syntax: crypto.verify(algorithm, data, publicKey, signature) Parameters: algorithm: It is a stri 2 min read Node.js crypto.scryptSync( ) Function The crypto.scryptSync() is an inbuilt function which Provides a synchronous scrypt implementation in Node.js. scrypt is a password-based key derivation function. It is intended to be costly computationally plus memory-wise. So, the brute-force attacks are made unsuccessful. Syntax: crypto.scryptSync 3 min read Node.js crypto.randomUUID( ) Function The crypto.randomUUID() is  an inbuilt application programming interface of class Crypto within crypto module which is used to generate a random RFC 4122 Version 4 UUID. Syntax: const crypto.randomUUID([options]) Parameters: This function takes the disableEntropyCache as a parameter Return Value: Th 1 min read Node.js crypto.timingSafeEqual() Function Node.js is a cross-platform, open-source back-end JavaScript runtime environment that uses the V8 engine to execute JavaScript code outside of a web browser. Node.js allows developers to utilize JavaScript to create command-line tools and server-side scripting, which involves running scripts on the 2 min read Node.js crypto.hkdf() Function The crypto.hkdf() is  an inbuilt application programming interface of class Crypto within crypto module which is used to derive a key of the particular length. Syntax: const crypto.hkdf(digest, key, salt, info, keylen, callback) Parameters: This function takes the following arguments as the paramete 2 min read Node.js crypto.checkPrime() Function The crypto.checkPrime() is an inbuilt application programming interface of class Crypto within the crypto module which is used to check if the passed buffer object is prime or not. Syntax: const crypto.checkPrime(candidate[, options, [callback]])Parameters: This API takes the following arguments as 2 min read Node.js crypto.checkPrimeSync() Function The checkPrimeSync() is  an inbuilt application programming interface of class Crypto within crypto module which is used to check if the passed buffer object is prime or not. Syntax: const crypto.checkPrimeSync(candidate[, options]) Parameters: This function takes the following arguments as the para 2 min read Like