Skip to content
FutureBlitz

    Install

    Import std.crypto.blake3

    std.crypto.blake3

    Blake3, over BLAKE3's C code: a fast cryptographic hash of any length, 32 bytes unless asked for more or fewer, which can be keyed, as a MAC, or derive a key for a context, as a KDF.

    std/crypto/blake3.fb

    Types

    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.

    std/crypto/blake3.fb, line 17

    • Public New() constructor #

      A plain hash.

    • @PanicsAtCaller Public Static Method Keyed(key: UInt8[]): Blake3 static method #

      A hasher whose hash is a MAC with key, 32 bytes. Panics unless key is 32 bytes.

    • Public Static Method DerivingKey(context: String): Blake3 static method #

      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 "game 2026-10-23 save file encryption", so keys for different uses differ.

    • @PanicsAtCaller Public Static Method Hash(data: UInt8[], length: Int = 32): UInt8[] static method #

      data's hash, length bytes long. Panics when length is negative.

    • @PanicsAtCaller Public Static Method Hash(text: String, length: Int = 32): UInt8[] static method #

      The hash of text's UTF-8 bytes, length bytes long. Panics when length is negative.

    • @PanicsAtCaller Public Static Method KeyedHash(key: UInt8[], data: UInt8[], length: Int = 32): UInt8[] static method #

      data's MAC with key, 32 bytes. Panics unless key is 32 bytes, or when length is negative.

    • @PanicsAtCaller Public Static Method DeriveKey(context: String, material: UInt8[], length: Int = 32): UInt8[] static method #

      A key for context from material. Panics when length is negative.

    • Public Method Add(data: UInt8[]) method #

      Adds data to what it hashes.

    • Public Method Add(text: String) method #

      Adds text's UTF-8 bytes to what it hashes.

    • Public Method Finish(): UInt8[] method #

      The 32-byte hash of what was added, after which the hasher starts again, empty.

    • @PanicsAtCaller Public Method Finish(length: Int): UInt8[] method #

      The same, length bytes long, the first 32 of which are the 32-byte hash. Panics when length is negative.

    Report an issue with this page or with FutureBlitz on GitHub.