class Aws::TreeHash


into a single TreeHash, then call {#digest} on the final tree hash.
data are complete, you can rejoin their {#hashes} in sequential order
a seperate TreeHash object to compute hashes. Once all sections of
that are evenly divisible by 1MB. Each section of data requires
chunks concurrently, you must break the original file/data into sections
If you have a large object/file, and you would like to compute the
chunk may be smaller than 1MB.
* You must call {#update} with 1MB chunks of data. Only the final
TreeHash.new(tree_hashes.map(&:hashes).flatten)
a single TreeHash and then call {#digest}
compute a tree hash of a large object. Join their hashes at the end into
* TreeHash is not thread safe. Use multiple TreeHash objects to concurrently
There are two main limitations to be aware of when using TreeHash:
== Limitations and Notes
tree_hash.digest
tree_hash.update(file.read(1024 * 1024)) until file.eof?
tree_hash = TreeHash.new
Used for computing a tree hash SHA256 checksum of an object.

def digest

def digest
  hashes = @hashes
  digest = OpenSSL::Digest.new('sha256')
  until hashes.count == 1
    hashes = hashes.each_slice(2).map do |h1,h2|
      digest.reset
      if h2
        digest.update(h1)
        digest.update(h2)
        digest.digest
      else
        h1
      end
    end
  end
  hashes.first.bytes.map{|x| x.to_i.to_s(16).rjust(2, '0')}.join('')
end

def initialize(hashes = [])

def initialize(hashes = [])
  @digest = OpenSSL::Digest.new('sha256')
  @hashes = hashes
end

def update(chunk)

Returns:
  • (String) - Returns the computed SHA256 digest of the chunk.

Parameters:
  • chunk (String) --
def update(chunk)
  @hashes << @digest.update(chunk).digest
  @digest.reset
  @hashes.last
end