Skip to content

Commit 257f2bc

Browse files
committed
Update docs and bump mix.exs to v2.1.0
1 parent 418cf3e commit 257f2bc

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This package can be installed via Hex:
1010
1. Add siphash to your list of dependencies in `mix.exs`:
1111

1212
def deps do
13-
[{:siphash, "~> 2.0.0"}]
13+
[{:siphash, "~> 2.1.0"}]
1414
end
1515

1616
2. Ensure siphash is started before your application:
@@ -32,13 +32,13 @@ iex(2)> SipHash.hash("0123456789ABCDEF", "Hello, World!", hex: true) # default i
3232

3333
For further examples, as well as different flags to customize output, please see the [documentation](http://hexdocs.pm/siphash/SipHash.html).
3434

35-
## Migration to v2.x
35+
## Migration to v2.1.x
3636

37-
Naturally I'm forced to I take back what I said in the v1.1.0 notes; v2.0.0 is now almost 20x faster than the original implementation (when using NIFs). Without NIFs it's only a few microseconds faster than v1.1.0, but faster nonetheless. Turns out the 64-bit masks in v1.x were causing a bottleneck (since they have to be applied so often). Once these were migrated to NIFs, everything became much faster.
37+
The move to v2.1.x comes with even further performance gains, roughly 3x the speed of v2.0.x. There are a few notable changes in this version bump which make it necessary to document;
3838

39-
If for any reason you desire to use the pure Elixir implementation without using NIFs, you can set the `HASH_IMPL` environment variable to `embedded`. Please note that there is likely a significant performance hit when doing this, so I don't recommend it. The embedded implementation is also the fallback in case a NIF cannot be loaded for some reason (a message is logged on startup displaying which implementation is being used).
39+
Previously, NIFs were disabled by setting `HASH_IMPL` to `embedded` in your environment. As of v2.1.x, there are two places native implementations are used, and so they have to be disabled separately via the `STATE_IMPL` and `UTIL_IMPL` environment variables. Setting them to `embedded` will force them to use an internal Elixir implementation (which will very likely be slower). Both can be disabled independently of each other.
4040

41-
This release also made `SipHash.hash/3` come more inline with actual SipHash, in that it returns the numeric result rather than Hex. The reason for this is that the Hex conversion is additional overhead, and it's incorrect to assume everyone wants this format. To replicate the old behaviour, just supply `hex: true` in the option list passed to `SipHash.hash/3` (example above).
41+
Please also note that as of v2.1.x, the `:padding` key does not change any behaviour. In prior versions it was possible to **not** left-pad your hashes with 0s (in Hex). This has been removed because it make a lot of things a pain, and it's arguably an unneeded use case anyway. As such, all hashes will be left-padded to 16 bytes as required (by default, and unnegotiable).
4242

4343
## Issues/Contributions
4444

lib/siphash.ex

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ defmodule SipHash do
4949
* `:case` - either of `:upper` or `:lower`, defaults to using `:upper`
5050
* `:c` and `:d` - the number of compression rounds, default to `2` and `4`
5151
* `:hex` - when `true` returns the output as a hex string
52-
* `:padding` - when `true`, pads left with zeroes to 16 chars as necessary
5352
5453
## Examples
5554
@@ -68,9 +67,6 @@ defmodule SipHash do
6867
iex> SipHash.hash("0123456789ABCDEF", "hello", hex: true, case: :lower)
6968
"3d1974e948748ce2"
7069
71-
iex> SipHash.hash("0123456789ABCDEF", "zymotechnics", hex: true, padding: :true)
72-
"09B57037CD3F8F0C"
73-
7470
iex> SipHash.hash("0123456789ABCDEF", "hello", c: 4, d: 8)
7571
14986662229302055855
7672

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ defmodule SipHash.Mixfile do
2626
},
2727
maintainers: [ "Isaac Whitfield" ]
2828
},
29-
version: "2.0.1",
29+
version: "2.1.0",
3030
elixir: "~> 1.1",
3131
aliases: [
3232
clean: [ "clean", "clean.make" ]

0 commit comments

Comments
 (0)