Class: IsccLib::DataHasher

Inherits:
Object
  • Object
show all
Defined in:
lib/iscc_lib.rb

Overview

Streaming Data-Code generator (reopens native class).

Incrementally processes data with content-defined chunking and MinHash to produce results identical to gen_data_code_v0.

Examples:

hasher = IsccLib::DataHasher.new
hasher.update(chunk1).update(chunk2)
result = hasher.finalize(bits: 64)

Instance Method Summary collapse

Instance Method Details

#finalize(bits: 64) ⇒ DataCodeResult

Consume the hasher and produce a Data-Code result.

Parameters:

  • bits (Integer) (defaults to: 64)

    bit length (default: 64)

Returns:

Raises:

  • (RuntimeError)

    if called more than once



202
203
204
# File 'lib/iscc_lib.rb', line 202

def finalize(bits: 64)
  DataCodeResult[_finalize(bits)]
end

#update(data) ⇒ self

Push binary data into the hasher.

Parameters:

  • data (String)

    binary data

Returns:

  • (self)

    for method chaining



192
193
194
195
# File 'lib/iscc_lib.rb', line 192

def update(data)
  _update(data)
  self
end