module HashHelper

Public Instance Methods

hash160( bytes ) click to toggle source
# File lib/bytes.rb, line 105
def hash160( bytes )
  ## double - uses ripemd160(sha256())
  ripemd160(sha256( bytes ))
end
hash256( bytes ) click to toggle source
# File lib/bytes.rb, line 100
def hash256( bytes )
  ## double - uses sha256(sha256())
  sha256(sha256( bytes ))
end
ripemd160( bytes ) click to toggle source
# File lib/bytes.rb, line 95
def ripemd160( bytes )
  ## todo/fix:  check bytes.encoding - warn if not BINARY!!!!
  Digest::RMD160.digest( bytes )
end
ripemd160hex( bytes ) click to toggle source
# File lib/bytes.rb, line 112
def ripemd160hex( bytes ) Bytes.to_hex(ripemd160( bytes )); end
sha256( bytes ) click to toggle source
# File lib/bytes.rb, line 90
def sha256( bytes )
  ## todo/fix:  check bytes.encoding - warn if not BINARY!!!!
  Digest::SHA256.digest( bytes )
end
sha256hex( bytes ) click to toggle source

convenience shortcut helpers

# File lib/bytes.rb, line 111
def sha256hex( bytes )    Bytes.to_hex(sha256( bytes ));    end