turbo.hash – Cryptographic Hashes

Wrappers for the OpenSSL crypto library.

SHA1 class

SHA1(str)

Create a SHA1 object. Pass a Lua string with the initializer to digest it.

Parameters:str (String or nil) – Lua string to digest immediately. Note that you cannot call SHA1.update or SHA1.final afterwards as the digest is already final.
SHA1:update(str)

Update SHA1 context with more data

Parameters:str – String
hash.SHA1:final()

Finalize SHA1 context

Return type:(char*) Message digest.
SHA1:__eq(cmp)

Compare two SHA1 contexts with the equality operator ==.

Return type:(Boolean) True or false.
SHA1:hex()

Convert message digest to Lua hex string.

Return type:String
HMAC(key, digest)

Keyed-hash message authentication code (HMAC) is a specific construction for calculating a message authentication code (MAC) involving a cryptographic hash function in combination with a secret cryptographic key.

Parameters:
  • key (String) – Sequence of bytes used as a key.
  • digest (String) – String to digest.
Return type:

String. Hex representation of digested string.