Sha256: a6e6aa65cfb7871273635fd4ba9e957860560fe484dd3557778a7f9da72fc876

Contents?: true

Size: 825 Bytes

Versions: 1

Compression:

Stored size: 825 Bytes

Contents

require 'xxhash/version'
require 'xxhash/xxhash'

module XXhash
  def self.xxh32(input, seed = 0)
    XXhashInternal.xxh32(input, seed)
  end

  def self.xxh64(input, seed = 0)
    XXhashInternal.xxh64(input, seed)
  end

  def self.xxh32_stream(io, seed = 0, chunk_size = 32)
    raise ArgumentError, 'first argument should be IO' if !io.is_a?(IO) && !io.is_a?(StringIO)

    hash = XXhashInternal::StreamingHash32.new(seed)

    while chunk = io.read(chunk_size)
      hash.update(chunk)
    end

    hash.digest
  end

  def self.xxh64_stream(io, seed = 0, chunk_size = 32)
    raise ArgumentError, 'first argument should be IO' if !io.is_a?(IO) && !io.is_a?(StringIO)

    hash = XXhashInternal::StreamingHash64.new(seed)

    while chunk = io.read(chunk_size)
      hash.update(chunk)
    end

    hash.digest
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
xxhash-0.3.0 lib/xxhash.rb