Module: HashHelper

Defined in:
lib/bytes.rb

Instance Method Summary collapse

Instance Method Details

#hash160(bytes) ⇒ Object



105
106
107
108
# File 'lib/bytes.rb', line 105

def hash160( bytes )
  ## double - uses ripemd160(sha256())
  ripemd160(sha256( bytes ))
end

#hash256(bytes) ⇒ Object



100
101
102
103
# File 'lib/bytes.rb', line 100

def hash256( bytes )
  ## double - uses sha256(sha256())
  sha256(sha256( bytes ))
end

#ripemd160(bytes) ⇒ Object



95
96
97
98
# 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) ⇒ Object



112
# File 'lib/bytes.rb', line 112

def ripemd160hex( bytes ) Bytes.to_hex(ripemd160( bytes )); end

#sha256(bytes) ⇒ Object



90
91
92
93
# 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) ⇒ Object

convenience shortcut helpers



111
# File 'lib/bytes.rb', line 111

def sha256hex( bytes )    Bytes.to_hex(sha256( bytes ));    end