Class: Stribog::CreateHash

Inherits:
Object
  • Object
show all
Defined in:
lib/stribog/create_hash.rb

Overview

Hash function

Author:

  • WildDima

Constant Summary collapse

HASH_LENGTH =
512

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, binary_vector: BinaryVector) ⇒ CreateHash

Returns a new instance of CreateHash.



11
12
13
14
15
16
# File 'lib/stribog/create_hash.rb', line 11

def initialize(message, binary_vector: BinaryVector)
  @binary_vector = binary_vector
  @message = binary_vector.from_hex(message)
  @n = binary_vector_field_by
  @sum = binary_vector_field_by
end

Instance Attribute Details

#binary_vectorObject (readonly)

Returns the value of attribute binary_vector.



7
8
9
# File 'lib/stribog/create_hash.rb', line 7

def binary_vector
  @binary_vector
end

#digest_lengthObject (readonly)

Returns the value of attribute digest_length.



7
8
9
# File 'lib/stribog/create_hash.rb', line 7

def digest_length
  @digest_length
end

#messageObject (readonly)

Returns the value of attribute message.



7
8
9
# File 'lib/stribog/create_hash.rb', line 7

def message
  @message
end

#message_adapterObject (readonly)

Returns the value of attribute message_adapter.



7
8
9
# File 'lib/stribog/create_hash.rb', line 7

def message_adapter
  @message_adapter
end

#message_vectorObject (readonly)

Returns the value of attribute message_vector.



7
8
9
# File 'lib/stribog/create_hash.rb', line 7

def message_vector
  @message_vector
end

Instance Method Details

#call(digest_length = HASH_LENGTH) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/stribog/create_hash.rb', line 18

def call(digest_length = HASH_LENGTH)
  create_hash_params!(digest_length: digest_length)

  return_hash(
    final_compression(
      core_hashing(
        compact_message(
          sum: @sum,
          n: @n,
          message_vector: message_vector,
          hash_vector: @hash_vector
        )
      )
    )
  )
end