Skip to content
/ b3 Public

Pure Elixir implementation of the BLAKE3 hashing function.

License

Notifications You must be signed in to change notification settings

lebrunel/b3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

B3

Hex.pm License Build Status

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

As well as regular hash, B3 is a PRF, MAC, KDF, and XOF. That's a lot of acronyms!

B3 is a pure Elixir port of the BLAKE3 reference implementation. Zero dependencies will make compilation and deployments simple, but if its performance you're after, you may want to check out the blake3 package which uses Rustler to bind to the Rust BLAKE3 implementation.

Installation

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

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

Usage

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

  • B3.hash/2 - Returns a hash of the given message.
  • B3.keyed_hash/3 - Returns a keyed hash of the given message. Key must be 32 bytes.
  • B3.derive_key/3 - Derives a key from the given key material and context string.

All functions accept a keyword list of options:

  • :length - length in bytes of the resulting digest (default 32)
  • :encoding - optional encoding of the resulting digest (from :base16, :base64 or :hex)

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

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

© Copyright 2023 lebrunel.

About

Pure Elixir implementation of the BLAKE3 hashing function.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages