Import std.crypto.blake3
Blake3
class
Public Class Blake3 Implements Hasher
BLAKE3's hash of what's added in turn, of any length, for checksums, keys, and anything else a fast cryptographic hash fits.
Examples
Local hash = Blake3.Hash("abc")
Expect(hash.Count == 32)
Local hasher = Blake3()
hasher.Add("a")
hasher.Add("bc")
Expect(hasher.Finish() == hash)
Expect(Blake3.Hash("abc", 64).Count == 64)-
A plain hash.
-
A hasher whose hash is a MAC with
key, 32 bytes. Panics unlesskeyis 32 bytes. -
A hasher whose hash is a key for
context, from the material added:context, fixed in the program, says what the key is for, like "example.com save files, version 1", so keys for different uses differ. -
data's hash,lengthbytes long. Panics whenlengthis negative. -
The hash of
text's UTF-8 bytes,lengthbytes long. Panics whenlengthis negative. -
@PanicsAtCaller Public Static Method KeyedHash(key: UInt8[], data: UInt8[], length: Int = 32): UInt8[]static method #data's MAC withkey, 32 bytes. Panics unlesskeyis 32 bytes, or whenlengthis negative. -
@PanicsAtCaller Public Static Method DeriveKey(context: String, material: UInt8[], length: Int = 32): UInt8[]static method #A key for
contextfrommaterial. Panics whenlengthis negative.Examples
Local material = SecureRandom.Bytes(32) Local saves = Blake3.DeriveKey("example.com save files, version 1", material) Local tokens = Blake3.DeriveKey("example.com session tokens, version 1", material) Expect(saves.Count == 32 && saves != tokens) -
Adds
datato what it hashes. -
Adds
text's UTF-8 bytes to what it hashes. -
The 32-byte hash of what was added, after which the hasher starts again, empty.
-
The same,
lengthbytes long, the first 32 of which are the 32-byte hash. Panics whenlengthis negative.
Report an issue with this page or with FutureBlitz on GitHub.