Skip to content

Pure Scala port of the BLAKE3 reference implementation.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

omarjatoi/Scala-BLAKE3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

68f24b1 · Apr 2, 2025

History

30 Commits
Mar 24, 2025
Mar 24, 2025
Mar 24, 2025
Mar 26, 2025
Mar 24, 2025
Mar 24, 2025
Mar 24, 2025
Mar 28, 2025
Mar 24, 2025
Apr 2, 2025
Apr 2, 2025

Repository files navigation

Scala-BLAKE3

This is a pure Scala port of the BLAKE3 reference implementation.

Note

This is not an optimized implementation, if you're looking for something fast and stable to use in production, consider using the BLAKE3 implementations in Bouncy Castle or Apache Commons Codec.

Another optimized Scala implementation exists at https://github.com/kcrypt/scala-blake3.

Usage

val hasher = Blake3.Hasher()
hasher.update("scala".getBytes)
val hash = new Array[Byte](32)
hasher.finalize(hash)

Development

You can use nix to launch a development shell, i.e.:

φ nix develop --command /bin/zsh

Alternatively, install Scala and sbt, preferably using Couriser.

φ sbt test
...
Blake3TestVectors:
  + Input length 0 - all at once 0.013s
  + Input length 0 - one byte at a time 0.001s
  + Input length 1 - all at once 0.001s
  + Input length 1 - one byte at a time 0.001s
  + Input length 2 - all at once 0.001s
  + Input length 2 - one byte at a time 0.001s
  + Input length 3 - all at once 0.001s
  + Input length 3 - one byte at a time 0.001s
  + Input length 4 - all at once 0.001s
  + Input length 4 - one byte at a time 0.0s
  + Input length 5 - all at once 0.001s
  + Input length 5 - one byte at a time 0.001s
  + Input length 6 - all at once 0.0s
  + Input length 6 - one byte at a time 0.001s
  + Input length 7 - all at once 0.001s
  + Input length 7 - one byte at a time 0.0s
  + Input length 8 - all at once 0.001s
  + Input length 8 - one byte at a time 0.0s
  + Input length 63 - all at once 0.001s
  + Input length 63 - one byte at a time 0.0s
  + Input length 64 - all at once 0.001s
  + Input length 64 - one byte at a time 0.0s
  + Input length 65 - all at once 0.001s
  + Input length 65 - one byte at a time 0.0s
  + Input length 127 - all at once 0.0s
  + Input length 127 - one byte at a time 0.001s
  + Input length 128 - all at once 0.0s
  + Input length 128 - one byte at a time 0.001s
  + Input length 129 - all at once 0.0s
  + Input length 129 - one byte at a time 0.001s
  + Input length 1023 - all at once 0.0s
  + Input length 1023 - one byte at a time 0.001s
  + Input length 1024 - all at once 0.0s
  + Input length 1024 - one byte at a time 0.001s
  + Input length 1025 - all at once 0.001s
  + Input length 2048 - all at once 0.0s
  + Input length 2049 - all at once 0.001s
  + Input length 3072 - all at once 0.0s
  + Input length 3073 - all at once 0.001s
  + Input length 4096 - all at once 0.001s
  + Input length 4097 - all at once 0.0s
  + Input length 5120 - all at once 0.001s
  + Input length 5121 - all at once 0.001s
  + Input length 6144 - all at once 0.001s
  + Input length 6145 - all at once 0.0s
  + Input length 7168 - all at once 0.001s
  + Input length 7169 - all at once 0.001s
  + Input length 8192 - all at once 0.001s
  + Input length 8193 - all at once 0.001s
  + Input length 16384 - all at once 0.0s
  + Input length 31744 - all at once 0.002s
  + Input length 102400 - all at once 0.002s
  + Default output matches first 32 bytes of extended output 0.0s
  + Multiple updates with same total content produce the same result 0.001s
  + Different inputs produce different hashes 0.0s
  + Key must be exactly 32 bytes 0.001s
[info] Passed: Total 56, Failed 0, Errors 0, Passed 56
[success] Total time: 0 s, completed Mar 23, 2025, 10:30:36 PM

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

Pure Scala port of the BLAKE3 reference implementation.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published