Module: SimpleEncrypt
- Defined in:
- lib/simple_encrypt.rb
Instance Method Summary collapse
- #decrypt_with_private_key(encrypted_string, private_key) ⇒ Object
- #encrypt_with_public_key(string, public_key) ⇒ Object
Instance Method Details
#decrypt_with_private_key(encrypted_string, private_key) ⇒ Object
10 11 12 13 |
# 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) ⇒ Object
5 6 7 8 |
# 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 |