Module: ImtRb::Helper
- Included in:
- IncrementalMerkleTree
- Defined in:
- lib/imt_rb/helper.rb
Class Method Summary collapse
Instance Method Summary collapse
- #digest(str) ⇒ Object
- #hexdigest(str) ⇒ Object
- #to_binary(str) ⇒ Object
- #to_hex(binary_str) ⇒ Object
Class Method Details
.included(by) ⇒ Object
3 4 5 |
# File 'lib/imt_rb/helper.rb', line 3 def self.included(by) by.extend(self) end |
Instance Method Details
#digest(str) ⇒ Object
11 12 13 |
# File 'lib/imt_rb/helper.rb', line 11 def digest(str) Digest::Keccak256.new.digest(str) end |
#hexdigest(str) ⇒ Object
7 8 9 |
# File 'lib/imt_rb/helper.rb', line 7 def hexdigest(str) Digest::Keccak256.new.hexdigest(str) end |
#to_binary(str) ⇒ Object
15 16 17 |
# File 'lib/imt_rb/helper.rb', line 15 def to_binary(str) [str].pack("H*") end |
#to_hex(binary_str) ⇒ Object
19 20 21 |
# File 'lib/imt_rb/helper.rb', line 19 def to_hex(binary_str) binary_str.unpack1("H*") end |