Module: DiceBag::TemplateHelpers

Included in:
TemplateFile
Defined in:
lib/dice_bag/template_helpers.rb

Instance Method Summary collapse

Instance Method Details

#ensure_is_private_key(key) ⇒ Object


10
11
12
13
14
15
16
17
18
# File 'lib/dice_bag/template_helpers.rb', line 10

def ensure_is_private_key(key)
	pkey = PrivateKey.new key.dup
  pkey.to_rsa_format!
  if pkey.is_valid_private_key?
    pkey.private_key
  else
    raise "The private key provided is invalid"
  end
end

#generate_private_keyObject


5
6
7
8
# File 'lib/dice_bag/template_helpers.rb', line 5

def generate_private_key
  require 'openssl'
  OpenSSL::PKey::RSA.generate(2048)
end