Skip to content

infinity.md5

Provides functionality for creating MD5-hashes out of strings, files and streams.

Module: infinity.crypto

Functions:

Example:

infinity.loadModule('infinity.crypto');

let hash = infinity.md5.hash("dataToHash");
console.debug(hash);
//844fb0adcfe50cb7edf8bd26e5575383

Functions

hash()

Returns the md5 hash of the given string.

Signature:

hash( value: string ): string

Parameters:

  • value: string

    String to serve as the hash creation material.

Return type: string

Example:

infinity.loadModule('infinity.crypto');
let hashedData = infinity.md5.hash(dataToHash);

hashFile()

Returns the md5 hash of the contents of the given file.

Signature:

hashFile( fileName: string ): string

Parameters:

  • fileName: string

    Filename, relative path (location relative to the folder with the used INFINITY.JS executable file) or absolute path to the file which has to be hashed.

Return type: string

Example:

infinity.loadModule('infinity.crypto');
let hashedData = infinity.md5.hashFile('dataToHash.txt');

hashStream()

Generates the MD5 hash of the given stream.

Signature:

hashStream( stream: infinity.stream ): string

Parameters:

Return type: string

Example:

infinity.loadModule('infinity.crypto');
let hashedData = infinity.md5.hashStream(stream);

hmac()

Returns a keyed hash value using the HMAC method.

Signature:

hash( value: string, key: string ): string

Parameters:

  • value: string

    Message to be hashed.

  • key: string

    Shared secret key used for generating the HMAC variant of the message digest.

Return type: string

Example:

infinity.loadModule('infinity.crypto');
let hmac = infinity.md5.hmac(value, key);