class DiceBag::PrivateKey
Constants
- FOOTER
- HEADER
Attributes
private_key[RW]
Public Class Methods
new(key)
click to toggle source
# File lib/dice_bag/private_key.rb, line 7 def initialize(key) @private_key = key end
Public Instance Methods
public_key()
click to toggle source
# File lib/dice_bag/private_key.rb, line 30 def public_key rsa_object.public_key end
rsa_object()
click to toggle source
# File lib/dice_bag/private_key.rb, line 34 def rsa_object @rsa_object ||= OpenSSL::PKey::RSA.new(@private_key) end
to_rsa_format!()
click to toggle source
# File lib/dice_bag/private_key.rb, line 23 def to_rsa_format! strip_down_key body = @private_key.split(/\s+/) body = body.first.scan(/.{1,64}/) if body.length == 1 @private_key = [HEADER, body, FOOTER].flatten.join("\n") end
valid_private_key?()
click to toggle source
# File lib/dice_bag/private_key.rb, line 11 def valid_private_key? require "openssl" begin rsa_object true rescue => e puts "#{e.message}\n#{e.backtrace}" false end end
Private Instance Methods
strip_down_key()
click to toggle source
# File lib/dice_bag/private_key.rb, line 43 def strip_down_key @private_key.gsub!(HEADER, "") @private_key.gsub!(FOOTER, "") @private_key.strip! end