Class: Encryption::Keypair
- Inherits:
-
Object
- Object
- Encryption::Keypair
- Defined in:
- lib/modules/asymmetric/keypair.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(size = 2048, password = nil) ⇒ Keypair
constructor
A new instance of Keypair.
- #private_key ⇒ Object
- #public_key ⇒ Object
Constructor Details
#initialize(size = 2048, password = nil) ⇒ Keypair
Returns a new instance of Keypair.
4 5 6 7 |
# File 'lib/modules/asymmetric/keypair.rb', line 4 def initialize(size = 2048, password = nil) @keypair = OpenSSL::PKey::RSA.new(size) @password = password end |
Class Method Details
.generate(size = 2048, password = nil) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/modules/asymmetric/keypair.rb', line 17 def self.generate(size = 2048, password = nil) keypair = OpenSSL::PKey::RSA.new(size) public_key = PublicKey.new(keypair.public_key.to_s, password) private_key = PrivateKey.new(keypair.to_s, password) return public_key, private_key end |
Instance Method Details
#private_key ⇒ Object
13 14 15 |
# File 'lib/modules/asymmetric/keypair.rb', line 13 def private_key PrivateKey.new(@keypair.to_s, @password) end |