Class: Minisign::Signature
- Inherits:
-
Object
- Object
- Minisign::Signature
- 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.
Constructor Details
#initialize(str) ⇒ Signature
Returns a new instance of Signature.
9 10 11 |
# File 'lib/minisign/signature.rb', line 9 def initialize(str) @lines = str.split("\n") end |
Instance Method Details
#key_id ⇒ String
Returns the key id.
17 18 19 |
# File 'lib/minisign/signature.rb', line 17 def key_id encoded_signature[2..9].bytes.map { |c| c.to_s(16) }.reverse.join.upcase end |
#signature ⇒ String
Returns the global signature.
35 36 37 |
# File 'lib/minisign/signature.rb', line 35 def signature encoded_signature[10..] end |
#to_s ⇒ String
Returns The signature that can be written to a file.
40 41 42 |
# File 'lib/minisign/signature.rb', line 40 def to_s "#{@lines.join("\n")}\n" end |
#trusted_comment ⇒ String
Returns the trusted comment.
25 26 27 |
# File 'lib/minisign/signature.rb', line 25 def trusted_comment @lines[2].split('trusted comment: ')[1] end |
#trusted_comment_signature ⇒ String
Returns the signature for the trusted comment.
30 31 32 |
# File 'lib/minisign/signature.rb', line 30 def trusted_comment_signature Base64.decode64(@lines[3]) end |