Lunatik

crypto_shashClass

Lua interface to synchronous message digest (hash) algorithms, including HMAC.

Methods

crypto_shash:algname () Returns the driver-independent name of the algorithm the transform was allocated with.
crypto_shash:close () Releases the transform.
crypto_shash:digest (data) Computes the digest of data in a single call.
crypto_shash:digestsize () Returns the digest size in bytes.
crypto_shash:export () Exports the current internal hash state.
crypto_shash:final () Finalizes and returns the digest.
crypto_shash:finup (data) Feeds final data and returns the digest (update + final in one call).
crypto_shash:import (state) Restores a previously exported hash state.
crypto_shash:init () Initializes the hash state for incremental hashing.
crypto_shash:setkey (key) Sets the key (required for HMAC algorithms).
crypto_shash:update (data) Feeds data into the running hash.

Methods in detail

crypto_shash:algname ()
Returns the driver-independent name of the algorithm the transform was allocated with.

Returns

    string
crypto_shash:close ()
Releases the transform. A to-be-closed variable holding the object releases it the same way. Calling it again does nothing, and every other method raises “closed object” afterwards.

Returns

    nil
crypto_shash:digest (data)
Computes the digest of data in a single call.

Parameters

Returns

    string digest bytes

Raises

on hash failure
crypto_shash:digestsize ()
Returns the digest size in bytes.

Returns

    integer
crypto_shash:export ()
Exports the current internal hash state.

Returns

    string opaque state blob
crypto_shash:final ()
Finalizes and returns the digest.

Returns

    string digest bytes

Raises

on hash failure
crypto_shash:finup (data)
Feeds final data and returns the digest (update + final in one call).

Parameters

Returns

    string digest bytes

Raises

on hash failure
crypto_shash:import (state)
Restores a previously exported hash state.

Parameters

  • state string blob returned by export()

Raises

on length mismatch
crypto_shash:init ()
Initializes the hash state for incremental hashing.

Raises

on initialization failure
crypto_shash:setkey (key)
Sets the key (required for HMAC algorithms).

Parameters

Raises

on invalid key or algorithm error
crypto_shash:update (data)
Feeds data into the running hash.

Parameters

Raises

on hash failure