Bitcoin uses various hash functions, all of which are available in the module BTC::HashFunctions
.
All functions take binary string arguments and return binary strings.
Use hex conversion methods to convert string to/from hex encoding if needed.
You typically access these via BTC
object:
>> BTC.sha256("correct horse battery staple")
=> "\xc4\xbb\xcb\x1f..."
If you include Core Extensions, you can use these and some other functions directly on the String:
>> "correct horse battery staple".sha256.to_hex
=> "c4bbcb1fbec99d65bf59d85c8cb62ee2db963f0fe106f483d9afa73bd4e39a8a"
Returns a binary string compressed using SHA-1 algorithm.
Returns a binary string compressed using SHA-256 algorithm.
Returns a binary string compressed using SHA-512 algorithm.
Returns a binary string compressed using RIPEMD-160 algorithm.
Returns a binary string compressed using two passes of SHA-256 algorithm. Known in Bitcoin as Hash256.
Returns a binary string compressed using composition ripemd160(sha256(string))
. Known in Bitcoin as Hash160.