Class: Cloudcrypt::AsymmetricalCrypt

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudcrypt/asymmetrical_crypt.rb

Class Method Summary collapse

Class Method Details

.decrypt(private_key, data_to_dencrypt) ⇒ Object



10
11
12
13
14
# File 'lib/cloudcrypt/asymmetrical_crypt.rb', line 10

def self.decrypt(private_key,data_to_dencrypt)
    raise if ( private_key.empty? || data_to_dencrypt.empty?)
    private_key_rsa = OpenSSL::PKey::RSA.new(private_key)
    decrypted_data = private_key_rsa.private_decrypt(data_to_dencrypt)
end

.encrypt(public_key, data_to_encrypt) ⇒ Object



4
5
6
7
8
# File 'lib/cloudcrypt/asymmetrical_crypt.rb', line 4

def self.encrypt(public_key,data_to_encrypt)
    raise if ( public_key.empty? || data_to_encrypt.empty? )      
    public_key_rsa = OpenSSL::PKey::RSA.new(public_key)
    encrypted_data = public_key_rsa.public_encrypt(data_to_encrypt)
end