Class: Rsa::Tools::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/rsa/tools/generator.rb

Class Method Summary collapse

Class Method Details

.key_pairsObject

call this function if you just want to save it to your database & send string to others



7
8
9
10
# File 'lib/rsa/tools/generator.rb', line 7

def self.key_pairs
  private_key, public_key = generate_pairs
  return private_key.to_s, public_key.to_s
end

.pem_pairs(pri_path = nil, pub_path = nil) ⇒ Object

call this function if pem files were wanted



13
14
15
16
17
# File 'lib/rsa/tools/generator.rb', line 13

def self.pem_pairs(pri_path = nil, pub_path = nil)
  private_key, public_key = generate_pairs
  open 'keys/private_key.pem', 'w' do |io| io.write private_key.to_pem end
  open 'keys/public_key.pem',  'w' do |io| io.write public_key.to_pem  end
end