Class: Signer::Digester
- Inherits:
-
Object
- Object
- Signer::Digester
- Defined in:
- lib/signer/digester.rb
Overview
Class that holds OpenSSL::Digest
instance with some meta information for digesting in XML.
Instance Attribute Summary collapse
-
#symbol ⇒ Object
readonly
Returns the value of attribute symbol.
Instance Method Summary collapse
-
#digest(message) ⇒ Object
(also: #call)
Digest.
-
#digest_id ⇒ Object
XML-friendly name (for specifying in XML
DigestMethod
nodeAlgorithm
attribute). -
#digest_name ⇒ Object
Human-friendly name.
-
#digester ⇒ Object
Returns
OpenSSL::Digest
(or derived class) instance. -
#initialize(algorithm) ⇒ Digester
constructor
You may pass either a one of
:sha1
,:sha256
or:gostr3411
symbols orHash
with keys:id
with a string, which will denote algorithm in XML Reference tag and:digester
with instance of class with interface compatible withOpenSSL::Digest
class.
Constructor Details
#initialize(algorithm) ⇒ Digester
You may pass either a one of :sha1
, :sha256
or :gostr3411
symbols or Hash
with keys :id
with a string, which will denote algorithm in XML Reference tag and :digester
with instance of class with interface compatible with OpenSSL::Digest
class.
45 46 47 48 49 50 51 52 53 |
# File 'lib/signer/digester.rb', line 45 def initialize(algorithm) if algorithm.kind_of? Symbol @digest_info = DIGEST_ALGORITHMS[algorithm].dup @digest_info[:digester] = @digest_info[:digester].call @symbol = algorithm else @digest_info = algorithm end end |
Instance Attribute Details
#symbol ⇒ Object (readonly)
Returns the value of attribute symbol.
55 56 57 |
# File 'lib/signer/digester.rb', line 55 def symbol @symbol end |
Instance Method Details
#digest(message) ⇒ Object Also known as: call
Digest
58 59 60 |
# File 'lib/signer/digester.rb', line 58 def digest() self.digester.digest() end |
#digest_id ⇒ Object
XML-friendly name (for specifying in XML DigestMethod
node Algorithm
attribute)
75 76 77 |
# File 'lib/signer/digester.rb', line 75 def digest_id @digest_info[:id] end |
#digest_name ⇒ Object
Human-friendly name
70 71 72 |
# File 'lib/signer/digester.rb', line 70 def digest_name @digest_info[:name] end |
#digester ⇒ Object
Returns OpenSSL::Digest
(or derived class) instance
65 66 67 |
# File 'lib/signer/digester.rb', line 65 def digester @digest_info[:digester].reset end |