class Encryption::PKey

Public Class Methods

new(data, password = nil) click to toggle source
# File lib/modules/asymmetric/pkey.rb, line 4
def initialize(data, password = nil)
  if File.exist?(data)
    data = File.read(data)
  end

  if password.nil?
    @key = OpenSSL::PKey::RSA.new(data)
  else
    @key = OpenSSL::PKey::RSA.new(data, password)
  end
end

Public Instance Methods

to_pem(password = nil) click to toggle source
# File lib/modules/asymmetric/pkey.rb, line 20
def to_pem(password = nil)
  if password.nil? or password.empty?
    return @key.to_pem
  end

  cipher = OpenSSL::Cipher::Cipher.new('des3')
  @key.to_pem(cipher, password)
end
to_s() click to toggle source
# File lib/modules/asymmetric/pkey.rb, line 16
def to_s
  @key.to_s
end