SipHash
An Elixir implementation of the SipHash cryptographic hash family. Supports any variation, although defaults to SipHash-2-4. Current implementation aims to be functional with a focus on correctness; future versions will focus more on speed.
Notes From v1.1
With a few minor changes to how hashing is done, v1.1 is ~60% faster than the initial v1 implementation. Unfortunately, it looks unlikely that it will be possible to speed it up further; it appears the current wall is simply that of Elixir.
Installation
This package can be installed via Hex:
Add siphash to your list of dependencies in
mix.exs
:def deps do [{:siphash, "~> 1.1.0"}] end
Ensure siphash is started before your application:
def application do [applications: [:siphash]] end
Quick Usage
It’s straightforward to get going, you just supply your key and input to SipHash.hash/2
.
iex(1)> SipHash.hash("0123456789ABCDEF", "Hello, World!")
"EAC3F88552D81B4A"
For further examples, as well as different flags to customize output, please see the documentation.
Issues/Contributions
If you spot any issues with the implementation, please file an issue or even a PR. The faster we can make it, the better!
Make sure to test your changes though!
$ mix test --trace # test successes/failures
$ mix coveralls # code coverage, try keep 100% please!