crypto.getDiffieHellman()

crypto.getDiffieHellman(group_name) Creates a predefined DiffieHellman key exchange object. The supported groups are: 'modp1', 'modp2', 'modp5' (defined in RFC 2412, but see Caveats) and 'modp14', 'modp15', 'modp16', 'modp17', 'modp18' (defined in RFC 3526). The returned object mimics the interface of objects created by crypto.createDiffieHellman(), but will not allow changing the keys (with diffieHellman.setPublicKey() for example). The advantage of using this method is that the parties do not

crypto.getHashes()

crypto.getHashes() Returns an array with the names of the supported hash algorithms. Example: const hashes = crypto.getHashes(); console.log(hashes); // ['sha', 'sha1', 'sha1WithRSAEncryption', ...]

crypto.getCurves()

crypto.getCurves() Returns an array with the names of the supported elliptic curves. Example: const curves = crypto.getCurves(); console.log(curves); // ['secp256k1', 'secp384r1', ...]

crypto.createVerify()

crypto.createVerify(algorithm) Creates and returns a Verify object that uses the given algorithm. On recent OpenSSL releases, openssl list-public-key-algorithms will display the available signing algorithms. One example is 'RSA-SHA256'.

crypto.DEFAULT_ENCODING

crypto.DEFAULT_ENCODING The default encoding to use for functions that can take either strings or buffers. The default value is 'buffer', which makes methods default to Buffer objects. The crypto.DEFAULT_ENCODING mechanism is provided for backwards compatibility with legacy programs that expect 'binary' to be the default encoding. New applications should expect the default to be 'buffer'. This property may become deprecated in a future Node.js release.

crypto.createHmac()

crypto.createHmac(algorithm, key) Creates and returns an Hmac object that uses the given algorithm and key. The algorithm is dependent on the available algorithms supported by the version of OpenSSL on the platform. Examples are 'sha256', 'sha512', etc. On recent releases of OpenSSL, openssl list-message-digest-algorithms will display the available digest algorithms. The key is the HMAC key used to generate the cryptographic HMAC hash. Example: generating the sha256 HMAC of a file const fil

crypto.createSign()

crypto.createSign(algorithm) Creates and returns a Sign object that uses the given algorithm. On recent OpenSSL releases, openssl list-public-key-algorithms will display the available signing algorithms. One example is 'RSA-SHA256'.

crypto.createDiffieHellman()

crypto.createDiffieHellman(prime[, prime_encoding][, generator][, generator_encoding]) Creates a DiffieHellman key exchange object using the supplied prime and an optional specific generator. The generator argument can be a number, string, or Buffer. If generator is not specified, the value 2 is used. The prime_encoding and generator_encoding arguments can be 'binary', 'hex', or 'base64'. If prime_encoding is specified, prime is expected to be a string; otherwise a Buffer is expected. If ge

crypto.createDecipheriv()

crypto.createDecipheriv(algorithm, key, iv) Creates and returns a Decipher object that uses the given algorithm, key and initialization vector (iv). The algorithm is dependent on OpenSSL, examples are 'aes192', etc. On recent OpenSSL releases, openssl list-cipher-algorithms will display the available cipher algorithms. The key is the raw key used by the algorithm and iv is an initialization vector. Both arguments must be 'binary' encoded strings or buffers.

crypto.createHash()

crypto.createHash(algorithm) Creates and returns a Hash object that can be used to generate hash digests using the given algorithm. The algorithm is dependent on the available algorithms supported by the version of OpenSSL on the platform. Examples are 'sha256', 'sha512', etc. On recent releases of OpenSSL, openssl list-message-digest-algorithms will display the available digest algorithms. Example: generating the sha256 sum of a file const filename = process.argv[2]; const crypto = require(