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 = ENCRYPTION_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 60
|
#algorithm_name ⇒ String
Fetches the name of the algorithm used by the public key from a predefined list of names.
98 99 100 |
# File 'lib/pgp.rb', line 98 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 76
|
#encrypt(data, algorithm = ENCRYPTION_ALGORITHM_AES_128) ⇒ String
Encrypts data using the specified encryption algorithm.
114 115 116 |
# File 'lib/pgp.rb', line 114 def encrypt(data, algorithm = ENCRYPTION_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 84
|
#encryption_supported? ⇒ Boolean
Checks if the public key supports encryption.
|
# File 'lib/pgp.rb', line 68
|
#expired? ⇒ Boolean
Checks whether the public key has expired.
104 105 106 107 108 |
# File 'lib/pgp.rb', line 104 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 80
|
#fingerprint ⇒ String
Returns the fingerprint of the public key.
|
# File 'lib/pgp.rb', line 56
|
#inspect ⇒ String
Returns a string representation of the PublicKey object, including its fingerprint, algorithm name, and version.
92 93 94 |
# File 'lib/pgp.rb', line 92 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 64
|
#version ⇒ Integer
Returns the version of the public key.
|
# File 'lib/pgp.rb', line 72
|