Class: Stribog::Digest
- Inherits:
-
Object
- Object
- Stribog::Digest
- Defined in:
- lib/stribog/digest.rb
Overview
Digest
Class, returning by CreateHash#call Contains binary and hex representation of digest. You can use #binary to get array and #hex to get digest in hash.
Instance Attribute Summary collapse
-
#dec ⇒ Object
readonly
Returns the value of attribute dec.
-
#vector ⇒ Array
readonly
Contains binary representation of hash.
Instance Method Summary collapse
- #base64 ⇒ Object
- #hex ⇒ Object (also: #to_hex)
-
#initialize(vector:) ⇒ String
constructor
Contains hex value of hash.
- #pack(meaning = 'C*') ⇒ Object
Constructor Details
#initialize(vector:) ⇒ String
Contains hex value of hash
26 27 28 29 |
# File 'lib/stribog/digest.rb', line 26 def initialize(vector:) @vector = vector @dec = vector.to_dec end |
Instance Attribute Details
#dec ⇒ Object (readonly)
Returns the value of attribute dec.
18 19 20 |
# File 'lib/stribog/digest.rb', line 18 def dec @dec end |
#vector ⇒ Array (readonly)
Contains binary representation of hash
17 18 19 |
# File 'lib/stribog/digest.rb', line 17 def vector @vector end |
Instance Method Details
#base64 ⇒ Object
36 37 38 |
# File 'lib/stribog/digest.rb', line 36 def base64 Base64.encode64(dec.to_s) end |
#hex ⇒ Object Also known as: to_hex
31 32 33 |
# File 'lib/stribog/digest.rb', line 31 def hex dec.to_s(16) end |
#pack(meaning = 'C*') ⇒ Object
40 41 42 |
# File 'lib/stribog/digest.rb', line 40 def pack(meaning = 'C*') binary.to_byte_array.pack(meaning) end |