Class: Stribog::CreateHash
- Inherits:
-
Object
- Object
- Stribog::CreateHash
- Defined in:
- lib/stribog/create_hash.rb
Overview
CreateHash
Class, which creates digests.
Instance Attribute Summary collapse
-
#digest_length ⇒ Fixnum
readonly
Length of digest.
-
#message ⇒ String
readonly
Original message.
-
#message_vector ⇒ BinaryVector
readonly
Contain message as instance of BinaryVector.
-
#vector ⇒ Object
readonly
Returns the value of attribute vector.
Instance Method Summary collapse
-
#call(digest_length = HASH_LENGTH) ⇒ Object
Create digest of #message.
-
#initialize(message, transformation = :from_hex, vector = Stribog.vector) ⇒ CreateHash
constructor
A new instance of CreateHash.
Constructor Details
#initialize(message, transformation = :from_hex, vector = Stribog.vector) ⇒ CreateHash
Returns a new instance of CreateHash.
32 33 34 35 36 |
# File 'lib/stribog/create_hash.rb', line 32 def initialize(, transformation = :from_hex, vector = Stribog.vector) @message = @transformation = transformation @vector = vector end |
Instance Attribute Details
#digest_length ⇒ Fixnum (readonly)
Length of digest. Should be equal to 256 or 512.
21 22 23 |
# File 'lib/stribog/create_hash.rb', line 21 def digest_length @digest_length end |
#message ⇒ String (readonly)
Original message
13 14 15 |
# File 'lib/stribog/create_hash.rb', line 13 def @message end |
#message_vector ⇒ BinaryVector (readonly)
Contain message as instance of BinaryVector
29 30 31 |
# File 'lib/stribog/create_hash.rb', line 29 def @message_vector end |
#vector ⇒ Object (readonly)
Returns the value of attribute vector.
30 31 32 |
# File 'lib/stribog/create_hash.rb', line 30 def vector @vector end |
Instance Method Details
#call(digest_length = HASH_LENGTH) ⇒ Object
Create digest of #message. Default equal to 512.
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/stribog/create_hash.rb', line 44 def call(digest_length = HASH_LENGTH) @digest_length = digest_length return_hash( Stage::Final.new( Stage::Compression.new( Stage::Initial.new(self) ) ).call ) end |