crypto

D. Namespace

crypto

Description:
  • The Custom Driver Crypto object. Contains utility functions that offer ways of encapsulating secure credentials to be used as part of a secure HTTPS net or http connection. Offers a set of wrappers for OpenSSL's hash, hmac, cipher methods.
    For more information check the official node documentation:
    https://nodejs.org/docs/latest-v14.x/api/crypto.html
Example
D.crypto

Namespaces

Cipher
Decipher

Methods

(static) createCipher(algorithm, key, initializationVector) → {Cipher}

Description:
Example
// returns the Cipher object
D.crypto.createCipher('aes-128-ecb', 'the key', 'the initialization vector')
Parameters:
Name Type Description
algorithm string The algorithm is dependent on the available algorithms supported by the version of OpenSSL on the agent's host platform. Examples are 'sha1', 'md5', 'sha256', 'sha512', 'aes192', etc
key string | Buffer The key to be used. Must be 'binary' encoded strings or buffers.
initializationVector string | Buffer The initialization vector. Must be 'binary' encoded strings or buffers.
Returns:
Type
Cipher

(static) createDecipher(algorithm, key, initializationVector) → {Decipher}

Description:
Example
// returns the Decipher object
D.crypto.createDecipher('aes-128-ecb', 'the key', 'the initialization vector')
Parameters:
Name Type Description
algorithm string The algorithm is dependent on the available algorithms supported by the version of OpenSSL on the agent's host platform. Examples are 'sha1', 'md5', 'sha256', 'sha512', 'aes192', etc
key string | Buffer The key to be used. Must be 'binary' encoded strings or buffers.
initializationVector string | Buffer The initialization vector. Must be 'binary' encoded strings or buffers.
Returns:
Type
Decipher

(static) hash(data, algorithm, inputEncodingopt, outputEncodingopt) → {string|Buffer}

Description:
  • This is a utility function for creating hash digests of data.
Example
// returns '4130d2b39ca35eaf4cb95fc846c21ee6a39af698154a83a586ee270a0d372139' for the generated hash digest with 'utf8' input encoding and 'hex' output encoding.
D.crypto.hash('my data', 'sha256', 'utf8', 'hex')
Parameters:
Name Type Attributes Description
data string | Buffer The data object.
If data is a Buffer then inputEncoding is ignored.
algorithm string The cipher algorithm is dependent on the available algorithms supported by the version of OpenSSL on the agent's host platform.

Examples are 'sha1', 'md5', 'sha256', 'sha512', 'aes192', etc

inputEncoding binary | ascii | utf8 <optional>
The encoding of the data string.
outputEncoding binary | base64 | hex <optional>
The encoding of the return value.
If no encoding is provided, then a buffer is returned.
Returns:
Type
string | Buffer

(static) hmac(data, key, algorithm, outputEncodingopt) → {string|Buffer}

Description:
  • This is a utility function for creating cryptographic HMAC digests.
Example
// returns '049f32be4f33a698204529818c1b676d460c9cb2f6901457d012a6646127ae31' for the generated HMAC digest with hex output encoding
D.crypto.hmac('my data', 'my secret', 'sha256', 'hex')
Parameters:
Name Type Attributes Description
data string The data string
key string The HMAC key to be used.
algorithm string The cipher algorithm is dependent on the available algorithms supported by the version of OpenSSL on the agent's host platform.

Examples are 'sha1', 'md5', 'sha256', 'sha512', 'aes192', etc

outputEncoding binary | base64 | hex <optional>
The output encoding.
If no encoding is provided, then a buffer is returned.
Returns:
Type
string | Buffer

(static) pbkdf2Sync(password, salt, iterations, keyLength) → {string}

Description:
  • Synchronous PBKDF2 (Password-Based Key Derivation Function) Returns derivedKey or throws an error. * @example // returns the Derived key D.crypto.pbkdf2Sync('the password', 'the salt', 100, 10)
Parameters:
Name Type Description
password string The password
salt string The random bit of data added to the password before it is run through the hashing algorithm.
iterations integer The number of iterations for the key and salt mixing.
Higher iterrations count makes guessing the key harder.
keyLength integer The number of output bytes to be used for the algorithm.
Returns:
- Derived key
Type
string