metis.crypto.sha1

Calculate the SHA1 hash for some text.

SHA1 has been broken for several years now, and so should not be treated as secure. However, it is often a useful (and efficient) way to compute a checksum of a value.

Usage

create()Construct a new hash builder, to generate a SHA1 hash incrementally.
create()Source

Construct a new hash builder, to generate a SHA1 hash incrementally.

The sha1 module may be called as a function directly (see the module description) to compute the hash. However, in some circumstances it may be better to build a hash incrementally.

For instance, instead of reading a file in one go, one may read it in chunks and hash each chunk separately.

Returns

  1. Hash The hash builder.

Types

Hash

A "work in progress" hash, created with create.

The hash input may be extended with Hash:append and the final string computed with tostring.

Hash:append(str)Source

Append a string to this hash buffer.

Repeated calls to this function are equivalent to concatination: s:append(a) s:append(b) is equivalent to s:append(a .. b). The former should be preferred, as it is (generally) more efficient.

Parameters

  1. str string The string to hash.