Skip to content

nashby/xxhash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

92435eb · Dec 19, 2024

History

81 Commits
May 30, 2024
May 30, 2024
Dec 19, 2024
Jul 28, 2022
Dec 13, 2014
Dec 19, 2024
Jul 6, 2022
Dec 21, 2012
Dec 19, 2024
Jan 1, 2015
Sep 12, 2013

Repository files navigation

xxHash Ruby

Ruby wrapper for xxHash

Install

gem install xxhash

Usage

require 'xxhash'

text = "test"
seed = 12345

XXhash.xxh32(text, seed) # => 3834992036

If you do not provide a seed, it will use the default value 0.

You can use it with IO objects too:

XXhash.xxh32_stream(StringIO.new('test'), 123) # => 2758658570

You can use it with file path directly, avoiding costly ruby-related operations.

XXhash.xxh32_file(__FILE__)

Note that you can also pass a chunk size as third param (it's 32 bytes by default)

XXH64 is also supported: you can use xxh64, xxh64_stream, .xxh64_file.

Supported Ruby versions

  • MRI 3.1+

Note: It doesn't work on JRuby as it uses C extension.

Versioning

Version 0.6.0 is equal to 0.8.1

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Copyright

Copyright (c) 2024 Vasiliy Ermolovich. See LICENSE.txt for further details.