xxhash-crystal
xxhash-crystal
These are the crystal bindings for xxHash
- An extremely fast non-cryptographic hash algorithm
Installation
Add this to your application's shard.yml
:
dependencies:
xxhash:
github: jreinert/xxhash-crystal
Usage
This library provides bindings for both the 64 and 32 bit version of xxHash They are accessed through the modules XXHash32
and XXHash64
respectively.
You should use the one that matches your cpu architecture.
require "xxhash"
# Pass a nn-bit seed
seed = (Random::Secure.random_bytes(8).to_unsafe.as(UInt64*)).value
puts XXHash64.hex_digest("foobar", seed)
# Or use 0 by default
puts XXHash64.hex_digest("foobar")
# Stream data
XXHash64.open(seed) do |digester|
IO.copy(some_io, digester)
puts digester.hex_digest
end
Benchmarks
Run with make bench
. Set the DATA_SIZE_GIB
environment variable to alter used data size.
Hashing 16GiB of (semi)random data
user system total real
XXHash32 4.250000 0.000000 4.250000 ( 4.247582)
XXHash64 2.410000 0.000000 2.410000 ( 2.413591)
Contributing
- Fork it ( https://github.com/jreinert/xxhash/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
- jreinert Joakim Reinert - creator, maintainer
Repository
xxhash-crystal
Owner
Statistic
- 3
- 0
- 0
- 0
- 0
- almost 7 years ago
- November 7, 2015
License
MIT License
Links
Synced at
Sun, 22 Dec 2024 16:21:03 GMT
Languages