Node.js crypto.checkPrimeSync() Function Last Updated : 20 Jul, 2021 Comments Improve Suggest changes Like Article Like Report 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 parameter. candidate: This is an object of buffer representing a sequence of big endian octets of arbitrary length.option: The option which will alter the operation of this function. Return Value: This function returns true if and only if the candidate is a prime. Example 1: index.js // Node.js program to demonstrate the // crypto.checkPrimeSync() function // Importing crypto module const crypto = require('crypto') // creating and initializing new // ArrayBuffer object const buffer = new ArrayBuffer(8) // checking if the buffer object is prime or not // by using checkPrimeSync() method const val = crypto.checkPrimeSync(buffer) //display the result if(val) console.log("candidate is a prime") else console.log("candidate is not a prime") Run the index.js file using the following command: node index.js Output: candidate is not a prime Example 2: index.js // Node.js program to demonstrate the // crypto.checkPrimeSync() function // Importing crypto module const crypto = require('crypto') // creating and initializing new // BigInt object const buffer = BigInt("0o377777777777777777") // checking if the buffer object is prime or not // by using checkPrimeSync() method const val = crypto.checkPrimeSync(buffer) //display the result if(val) console.log("candidate is a prime") else console.log("candidate is not a prime") Run the index.js file using the following command: node index.js Output: candidate is not a prime Reference: https://nodejs.org/dist/latest-v15.x/docs/api/crypto.html#crypto_crypto_checkprimesync_candidate_options Comment More infoAdvertise with us Next Article Node.js crypto.checkPrimeSync() Function rohitprasad3 Follow Improve Article Tags : Web Technologies Node.js NodeJS-function Node.js-crypto-module Similar Reads 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 x509.checkPrivateKey() Function The x509.checkPrivateKey() is  an inbuilt application programming interface of class X509Certificate within crypto module which is used to check if the public key for this certificate is consistent with the given private key. Syntax: const x509.checkPrivateKey(privateKey) Parameters: This function t 2 min read 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.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.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 Like