Class BSV::Primitives::Ripemd160 ¶
Inherits: Object
Pure-Ruby implementation of RIPEMD-160.
Ported from the reference C implementation by Hans Dobbertin, Antoon Bosselaers, and Bart Preneel (https://homes.esat.kuleuven.be/~bosselae/ripemd160/).
RIPEMD-160 processes data in 512-bit (64-byte) blocks with 80 rounds split across two parallel paths (left and right). The five 32-bit state words are initialised to standard IV constants and updated via a Merkle-Damgård construction with Merkle-Damgård strengthening.
All arithmetic is 32-bit unsigned (masked with 0xFFFFFFFF after additions).
Usage: BSV::Primitives::Ripemd160.digest(data) # => 20-byte binary String
Constants¶
IV ¶
Initial hash values (little-endian words).
KL ¶
Left-path round constants (K_l).
KR ¶
Right-path round constants (K_r).
MASK32 ¶
Mask for 32-bit unsigned arithmetic.
RL ¶
Left-path message word selection (rounds 0-79).
RR ¶
Right-path message word selection (rounds 0-79).
SL ¶
Left-path rotation amounts (rounds 0-79).
SR ¶
Right-path rotation amounts (rounds 0-79).
Public Class Methods¶
digest(data) ¶
Compute the RIPEMD-160 digest of data. - @param data [String] input data (any encoding; treated as binary) - @return [String] 20-byte binary digest (ASCII-8BIT encoding)
Public Instance Methods¶
digest() ¶
- @return [String] 20-byte binary digest
initialize(data) ¶
- @param
data[String] input data - @raise [TypeError] if +data+ is not a String
- @return [Ripemd160] a new instance of Ripemd160