Search results

There are no results.

std.crypto.sha2

Implementations of the SHA256 and SHA512 hash functions.

Examples

import std.crypto.sha2 (Sha256)

let hasher = Sha256.new

hasher.write('hello'.to_byte_array)
hasher.finish.to_string # => '2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824'

Or when using the hash static method:

import std.crypto.sha2 (Sha256)

Sha256.hash('hello'.to_byte_array).to_string # => '2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824'

Limitations

The implementations of SHA256 and SHA512 use a 64-bits signed integer for tracking the total message size in bytes. This limits the total message size to 1024 PiB.

Classes

Sha256

A SHA256 hasher.

Sha512

A SHA512 hasher.