Class: Minisign::Signature
- Inherits:
-
Object
- Object
- Minisign::Signature
- Includes:
- Utils
- Defined in:
- lib/minisign/signature.rb
Overview
Parse a .minisig file’s contents
Instance Method Summary collapse
-
#initialize(str) ⇒ Signature
constructor
A new instance of Signature.
-
#key_id ⇒ String
The key id.
-
#signature ⇒ String
The global signature.
-
#to_s ⇒ String
The signature that can be written to a file.
-
#trusted_comment ⇒ String
The trusted comment.
-
#trusted_comment_signature ⇒ String
The signature for the trusted comment.
Methods included from Utils
#blake2b256, #blake2b512, #derive_key, #hex, #xor
Constructor Details
#initialize(str) ⇒ Signature
Returns a new instance of Signature.
10 11 12 13 |
# File 'lib/minisign/signature.rb', line 10 def initialize(str) @lines = str.split("\n") @decoded = Base64.strict_decode64(@lines[1]) end |
Instance Method Details
#key_id ⇒ String
Returns the key id.
19 20 21 |
# File 'lib/minisign/signature.rb', line 19 def key_id hex @decoded[2..9].bytes end |
#signature ⇒ String
Returns the global signature.
37 38 39 |
# File 'lib/minisign/signature.rb', line 37 def signature @decoded[10..] end |
#to_s ⇒ String
Returns The signature that can be written to a file.
42 43 44 |
# File 'lib/minisign/signature.rb', line 42 def to_s "#{@lines.join("\n")}\n" end |
#trusted_comment ⇒ String
Returns the trusted comment.
27 28 29 |
# File 'lib/minisign/signature.rb', line 27 def trusted_comment @lines[2].split('trusted comment: ')[1] end |
#trusted_comment_signature ⇒ String
Returns the signature for the trusted comment.
32 33 34 |
# File 'lib/minisign/signature.rb', line 32 def trusted_comment_signature Base64.decode64(@lines[3]) end |