Home Contents | # hash:init | Cipher/Hash | Core4 Lua Commands

## SYNOPSIS

success = hash:init(alg)

## DESCRIPTION

The Core4 system includes a copy of mbed TLS.

This function (re-)initializes an object for calculating one-way hashes (message digests).

The parameter alg names the desired message digest algorithm.

Supported algorithms are: MD2, MD4, MD5, SHA1, SHA224, SHA256, SHA384, SHA512, RIPEMD160.

After initialization, data is fed to the algorithme by calling hash:update().

The result can be retrieved by calling hash:finish().

## RETURN VALUE

On success, returns true.

If initialization failed, returns nil, a string describing the error and the mbedtls error code number.

## SEE ALSO

cipher.hash(), hash:update(), hash:finish()