Sha256: 3794ddbc9b1e613db86e02a03638c2e5267fe3609a70cdb4fcc432a560438c05

Contents?: true

Size: 511 Bytes

Versions: 2

Compression:

Stored size: 511 Bytes

Contents

require 'digest'

class CryptoconditionsRuby::Utils::Hasher < CryptoconditionsRuby::Utils::Writer
  attr_reader :digest_instance
  private :digest_instance

  def initialize(algorithm)
    if algorithm == 'sha256'
      @digest_instance = Digest::SHA256.new
    else
      raise NotImplementedError
    end
    super()
  end

  def write(in_bytes)
    digest_instance.update(in_bytes)
  end

  def digest
    digest_instance.digest
  end

  def self.length(algorithm)
    new(algorithm).digest.length
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cryptoconditions_ruby-0.5.2 lib/cryptoconditions_ruby/utils/hasher.rb
cryptoconditions_ruby-0.5.1 lib/cryptoconditions_ruby/utils/hasher.rb