2.5.5Functions

getSupportedHashes

Returns an array containing the names of all supported hashes.

getSupportedHashes()
ReturnAn array containing the names of all hashes supported by this module

This function can be used to check if different versions of the module support a specific hash.

hash

Convenience function that calculates a hash.

hash( raw, which, [data] )
raw If set to true, return a raw MemBuf instead of a string.
which Hash that should be used
data... Arbitrary amount of parameters that should be fed into the chosen hash function.
ReturnA lowercase hexadecimal string with the output of the chosen hash if raw is false, or a 1-byte wide MemBuf if true.
Raise
ParamError in case which is a string and a hash with that name was not found; or if which is not a hash object.
AccessError if which is a hash object that was already finalized.

This function takes an arbitrary amount of parameters. See HashBase.update() for details.

Param which can contain a String with the name of the hash, a hash class constructor, a not-finalized hash object, or a function that returns any of the latter.

Note: Use getSupportedHashes() to check which hash names are supported.

Note: If which is a hash object, it will be finalized by calling this function.

hmac

Provides HMAC authentication for a block of data

hmac( raw, which, key, data )
raw If set to true, return a raw MemBuf instead of a string.
which Hash that should be used
key Secret authentication key
data The data to be authenticated
ReturnA lowercase hexadecimal string with the HMAC-result of the chosen hash if raw is false, or a 1-byte wide MemBuf if true.
Raise
ParamError in case which is a string and a hash with that name was not found; or if which does not evaluate to a hash object.
AccessError if which evaluates to a hash object that was already finalized.

Param key can be a String or a MemBuf.

Param which can contain a String with the name of the hash, a hash class constructor, or a function that returns a useable hash object. Unlike the hash() function, it is not possible to pass a hash object directly, because it would have to be used 3 times, which is not possible because of finalization.

In total, this function evaluates which 3 times, creating 3 hash objects internally.

Note: Use getSupportedHashes() to check which hash names are supported.

makeHash

Creates a hash object based on the algorithm name

makeHash( name, [silent] )
name The name of the algorithm (case insensitive)
silent Return nil instead of throwing an exception, if the hash was not found
ReturnA new instance of a hash object of the the given algorithm name
Raise
ParamError in case a hash with that name was not found

Note: Use getSupportedHashes() to check which hash names are supported.

Made with http://www.falconpl.org