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().

A digest gives back the hash of its input, or it raises. It never gives back a hash of something else. Constructing one raises when OpenSSL cannot give it a context; append() and final() raise when OpenSSL could not do what was asked of them.

class ref Digest

Constructors

md5

[Source]

Use the MD5 algorithm to calculate the hash.

new ref md5()
: Digest ref^ ?

Returns


ripemd160

[Source]

Use the RIPEMD160 algorithm to calculate the hash.

new ref ripemd160()
: Digest ref^ ?

Returns


sha1

[Source]

Use the SHA1 algorithm to calculate the hash.

new ref sha1()
: Digest ref^ ?

Returns


sha224

[Source]

Use the SHA224 algorithm to calculate the hash.

new ref sha224()
: Digest ref^ ?

Returns


sha256

[Source]

Use the SHA256 algorithm to calculate the hash.

new ref sha256()
: Digest ref^ ?

Returns


sha384

[Source]

Use the SHA384 algorithm to calculate the hash.

new ref sha384()
: Digest ref^ ?

Returns


sha512

[Source]

Use the SHA512 algorithm to calculate the hash.

new ref sha512()
: Digest ref^ ?

Returns


shake128

[Source]

Use the SHAKE128 algorithm to calculate the hash.

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, the default size is always used.

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

Parameters

Returns


shake256

[Source]

Use the SHAKE256 algorithm to calculate the hash.

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, the default size is always used.

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 digest of the strings passed to the append() method. A second call returns the hash the first one made.

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