B3

B3

Hex.pmLicenseBuild Status

B3 is a pure Elixir implementation of BLAKE3, a modern cryptographic hash function.

Ported from the official BLAKE3 reference implementation with zero dependencies — no Rust toolchain, no NIFs, no compilation headaches. The internals have been optimised for the BEAM, so while pure Elixir will never match native code, B3 is as fast as BLAKE3 gets without leaving the BEAM.

As well as regular hashing, B3 is a PRF, MAC, KDF, and XOF. That’s a lot of acronyms, but what it means is that B3 can do keyed hashing (MAC/PRF), key derivation (KDF), and produce variable-length output (XOF) — all from a single algorithm.

Installation

The package can be installed by adding b3 to your list of dependencies in mix.exs.

def deps do
  [
    {:b3, "~> 0.2"}
  ]
end

Usage

The B3 module provides three functions for all your hashing and key derivation needs:

All functions accept a keyword list of options:

Examples

B3.hash("test", encoding: :hex)
"4878ca0425c739fa427f7eda20fe845f6b2e46ba5fe2a14df5b1e32f50603215"

B3.keyed_hash("test", "testkeytestkeytestkeytestkeytest", encoding: :hex)
"8bacb5b968184e269491c5022ec75d6b599ecf210ee3bb3a5208c1376f919202"

B3.derive_key("test", "[Test app] 1 Oct 2022 - Test keys", encoding: :hex)
"79bb09c3d5f99890ef4a24316036dd7707e9c0e9d3315de168248e666639438d"

License

B3 is open source and released under the Apache-2 License.

© Copyright 2023-2026 Push Code Ltd.