Skip to content

Digest

[Source]

Produces a hash from the chunks of input. Feed the input with append() and produce a final hash from the concatenation of the input with final().

append() accumulates input; final() returns the hash of the concatenation, or raises. It never returns a hash of anything other than what was appended. Construction raises when OpenSSL fails to allocate a context; append() and final() raise when OpenSSL reports failure.

class ref Digest

Constructors

md5

[Source]

16-byte (128-bit) hash.

new ref md5()
: Digest ref^ ?

Returns


ripemd160

[Source]

20-byte (160-bit) hash.

new ref ripemd160()
: Digest ref^ ?

Returns


sha1

[Source]

20-byte (160-bit) hash.

new ref sha1()
: Digest ref^ ?

Returns


sha224

[Source]

28-byte (224-bit) hash.

new ref sha224()
: Digest ref^ ?

Returns


sha256

[Source]

32-byte (256-bit) hash.

new ref sha256()
: Digest ref^ ?

Returns


sha384

[Source]

48-byte (384-bit) hash.

new ref sha384()
: Digest ref^ ?

Returns


sha512

[Source]

64-byte (512-bit) hash.

new ref sha512()
: Digest ref^ ?

Returns


shake128

[Source]

SHAKE128 is an extendable output function (XOF) that can produce variable-length output. The size' parameter controls the output length in bytes (default: 16). Variable-length output requires OpenSSL 3.0.x or OpenSSL 4.0.x; on OpenSSL 1.1.x, only the default size is accepted.

new ref shake128(
  size': USize val = 16)
: Digest ref^ ?

Parameters

Returns


shake256

[Source]

SHAKE256 is an extendable output function (XOF) that can produce variable-length output. The size' parameter controls the output length in bytes (default: 32). Variable-length output requires OpenSSL 3.0.x or OpenSSL 4.0.x; on OpenSSL 1.1.x, only the default size is accepted.

new ref shake256(
  size': USize val = 32)
: Digest ref^ ?

Parameters

Returns


Public Functions

append

[Source]

Update the digest with input.

Raises an error when final() has already been called, and when OpenSSL could not take the input.

fun ref append(
  input: ByteSeq)
: None val ?

Parameters

Returns


final

[Source]

Return the hash of the input passed to append(). A second call returns the hash the first one produced.

Raises an error when OpenSSL could not produce the hash. A digest that raises here has no hash to give, and raises from every later call.

fun ref final()
: Array[U8 val] val ?

Returns


digest_size

[Source]

Return the size of the message digest in bytes.

fun box digest_size()
: USize val

Returns