Class: PGP::PublicKey
- Inherits:
-
Object
- Object
- PGP::PublicKey
- Defined in:
- lib/pgp.rb
Overview
Public Key class provides an native extension representation for working with PGP public keys.
Class Method Summary collapse
-
.parse ⇒ PublicKey
Parses a PGP public key from a given string input.
Instance Method Summary collapse
-
#algorithm ⇒ Integer
Returns the algorithm used by the public key.
-
#algorithm_name ⇒ String
Fetches the name of the algorithm used by the public key from a predefined list of names.
-
#created_at ⇒ Time
Returns the creation time of the public key.
-
#encrypt(data, algorithm = ENCRIPTION_ALGORITHM_AES_128) ⇒ String
Encrypts data using the specified encryption algorithm.
-
#encrypt_with_algorithm(input, algorithm) ⇒ String
Encrypts data with the specified algorithm.
-
#encryption_supported? ⇒ Boolean
Checks if the public key supports encryption.
-
#expired? ⇒ Boolean
Checks whether the public key has expired.
-
#expires_at ⇒ Time?
Returns the expiration time of the public key, if any.
-
#fingerprint ⇒ String
Returns the fingerprint of the public key.
-
#inspect ⇒ String
Returns a string representation of the PublicKey object, including its fingerprint, algorithm name, and version.
-
#signing_supported? ⇒ Boolean
Checks if the public key supports signing.
-
#version ⇒ Integer
Returns the version of the public key.
Class Method Details
Instance Method Details
#algorithm ⇒ Integer
Returns the algorithm used by the public key.
|
# File 'lib/pgp.rb', line 55
|
#algorithm_name ⇒ String
Fetches the name of the algorithm used by the public key from a predefined list of names.
93 94 95 |
# File 'lib/pgp.rb', line 93 def algorithm_name KEY_ALGORITHM_NAMES.fetch(algorithm, 'Unknown') end |
#created_at ⇒ Time
Returns the creation time of the public key.
|
# File 'lib/pgp.rb', line 71
|
#encrypt(data, algorithm = ENCRIPTION_ALGORITHM_AES_128) ⇒ String
Encrypts data using the specified encryption algorithm.
109 110 111 |
# File 'lib/pgp.rb', line 109 def encrypt(data, algorithm = ENCRIPTION_ALGORITHM_AES_128) encrypt_with_algorithm(data, algorithm) end |
#encrypt_with_algorithm(input, algorithm) ⇒ String
Encrypts data with the specified algorithm.
|
# File 'lib/pgp.rb', line 79
|
#encryption_supported? ⇒ Boolean
Checks if the public key supports encryption.
|
# File 'lib/pgp.rb', line 63
|
#expired? ⇒ Boolean
Checks whether the public key has expired.
99 100 101 102 103 |
# File 'lib/pgp.rb', line 99 def expired? return false if expires_at.nil? expires_at.to_i <= Time.now.to_i end |
#expires_at ⇒ Time?
Returns the expiration time of the public key, if any.
|
# File 'lib/pgp.rb', line 75
|
#fingerprint ⇒ String
Returns the fingerprint of the public key.
|
# File 'lib/pgp.rb', line 51
|
#inspect ⇒ String
Returns a string representation of the PublicKey object, including its fingerprint, algorithm name, and version.
87 88 89 |
# File 'lib/pgp.rb', line 87 def inspect "#<#{self.class} #{fingerprint} #{algorithm_name} v#{version}>" end |
#signing_supported? ⇒ Boolean
Checks if the public key supports signing.
|
# File 'lib/pgp.rb', line 59
|
#version ⇒ Integer
Returns the version of the public key.
|
# File 'lib/pgp.rb', line 67
|