Class: Stribog::Digest

Inherits:
Object
  • Object
show all
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.

Author:

  • WildDima

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(vector:) ⇒ String

Contains hex value of hash

Examples:

digest.hex


26
27
28
29
# File 'lib/stribog/digest.rb', line 26

def initialize(vector:)
  @vector = vector
  @dec = vector.to_dec
end

Instance Attribute Details

#decObject (readonly)

Returns the value of attribute dec.



18
19
20
# File 'lib/stribog/digest.rb', line 18

def dec
  @dec
end

#vectorArray (readonly)

Contains binary representation of hash

Examples:

digest.binary

Returns:

  • (Array)

    binary representation of digest



17
18
19
# File 'lib/stribog/digest.rb', line 17

def vector
  @vector
end

Instance Method Details

#base64Object



36
37
38
# File 'lib/stribog/digest.rb', line 36

def base64
  Base64.encode64(dec.to_s)
end

#hexObject 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