module SimpleEncrypt

Public Instance Methods

decrypt_with_private_key(encrypted_string, private_key) click to toggle source
# File lib/simple_encrypt.rb, line 10
def decrypt_with_private_key(encrypted_string, private_key)
  OpenSSL::PKey::RSA.new(private_key).
    private_decrypt(Base64.urlsafe_decode64(encrypted_string))
end
encrypt_with_public_key(string, public_key) click to toggle source
# File lib/simple_encrypt.rb, line 5
def encrypt_with_public_key(string, public_key)
  encrypted_string = OpenSSL::PKey::RSA.new(public_key).public_encrypt(string)
  Base64.urlsafe_encode64(encrypted_string)
end