Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

* added methods for KeyID and KeyFingerprint of Public Key packet. fi…

…xes #1.
  • Loading branch information...
commit 23b623acea0102bccb481e20b70b7b2028ccd2cf 1 parent fa1ad09
@nahi authored
Showing with 13 additions and 0 deletions.
  1. +4 −0 lib/pgp/packet/publickey.rb
  2. +9 −0 lib/pgp/packet/publickeysupport.rb
View
4 lib/pgp/packet/publickey.rb
@@ -29,6 +29,10 @@ def initialize(algorithm = nil)
super(6, algorithm)
end
+ def as_primarykey
+ self
+ end
+
private
def dump_body
View
9 lib/pgp/packet/publickeysupport.rb
@@ -14,6 +14,7 @@
require 'pgp/pkeyalgorithm'
+require 'pgp/hashalgorithm'
module PGP
@@ -61,6 +62,14 @@ def decrypt(cipher)
public_decrypt(cipher)
end
+ def keyfingerprint
+ HashAlgorithm.calc(2, as_primarykey.dump)
+ end
+
+ def keyid
+ keyfingerprint[-8, 8]
+ end
+
private
def public_encrypt(plain)
Please sign in to comment.
Something went wrong with that request. Please try again.