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.
39 40 41 42 43 44 45 46 47 |
# File 'lib/signer/digester.rb', line 39 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.
49 50 51 |
# File 'lib/signer/digester.rb', line 49 def symbol @symbol end |
Instance Method Details
#digest(message) ⇒ Object Also known as: call
Digest
52 53 54 |
# File 'lib/signer/digester.rb', line 52 def digest() self.digester.digest() end |
#digest_id ⇒ Object
XML-friendly name (for specifying in XML DigestMethod
node Algorithm
attribute)
69 70 71 |
# File 'lib/signer/digester.rb', line 69 def digest_id @digest_info[:id] end |
#digest_name ⇒ Object
Human-friendly name
64 65 66 |
# File 'lib/signer/digester.rb', line 64 def digest_name @digest_info[:name] end |
#digester ⇒ Object
Returns OpenSSL::Digest
(or derived class) instance
59 60 61 |
# File 'lib/signer/digester.rb', line 59 def digester @digest_info[:digester].reset end |