Module: XXhash
- Defined in:
- lib/xxhash.rb,
lib/xxhash/version.rb,
ext/xxhash/xxhash.c
Defined Under Namespace
Modules: XXhashInternal
Constant Summary collapse
- VERSION =
"0.6.0"
Class Method Summary collapse
- .xxh32(input, seed = 0) ⇒ Object
- .xxh32_file(filename, seed = 0) ⇒ Object
- .xxh32_stream(io, seed = 0, chunk_size = 32) ⇒ Object
- .xxh64(input, seed = 0) ⇒ Object
- .xxh64_file(filename, seed = 0) ⇒ Object
- .xxh64_stream(io, seed = 0, chunk_size = 32) ⇒ Object
Class Method Details
.xxh32(input, seed = 0) ⇒ Object
6 7 8 |
# File 'lib/xxhash.rb', line 6 def self.xxh32(input, seed = 0) XXhashInternal.xxh32(input.to_s, seed.to_i) end |
.xxh32_file(filename, seed = 0) ⇒ Object
14 15 16 |
# File 'lib/xxhash.rb', line 14 def self.xxh32_file(filename, seed = 0) XXhashInternal.xxh32_file(filename.to_s, seed.to_i) end |
.xxh32_stream(io, seed = 0, chunk_size = 32) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/xxhash.rb', line 22 def self.xxh32_stream(io, seed = 0, chunk_size = 32) seed = seed.to_i chunk_size = chunk_size.to_i raise ArgumentError, 'first argument should be IO' if !io.respond_to?(:read) hash = XXhashInternal::StreamingHash32.new(seed) while chunk = io.read(chunk_size) hash.update(chunk.to_s) end hash.digest end |
.xxh64(input, seed = 0) ⇒ Object
10 11 12 |
# File 'lib/xxhash.rb', line 10 def self.xxh64(input, seed = 0) XXhashInternal.xxh64(input.to_s, seed.to_i) end |
.xxh64_file(filename, seed = 0) ⇒ Object
18 19 20 |
# File 'lib/xxhash.rb', line 18 def self.xxh64_file(filename, seed = 0) XXhashInternal.xxh64_file(filename.to_s, seed.to_i) end |
.xxh64_stream(io, seed = 0, chunk_size = 32) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/xxhash.rb', line 36 def self.xxh64_stream(io, seed = 0, chunk_size = 32) seed = seed.to_i chunk_size = chunk_size.to_i raise ArgumentError, 'first argument should be IO' if !io.respond_to?(:read) hash = XXhashInternal::StreamingHash64.new(seed) while chunk = io.read(chunk_size) hash.update(chunk.to_s) end hash.digest end |