Created
October 29, 2018 18:15
-
-
Save allanbatista/0d9f9f541ad4d948656f95d690cefd6d to your computer and use it in GitHub Desktop.
Exemplo de encrypt de arquivo.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'openssl' | |
| key = OpenSSL::PKey::RSA.new(2048) | |
| public_key_s = key.public_key.to_s | |
| private_key_s = key.to_s(OpenSSL::Cipher::AES256.new(:CBC), "password") | |
| encrypted_data = OpenSSL::PKey::RSA.new(public_key_s).public_encrypt("data to encrypt") | |
| opened_data = OpenSSL::PKey::RSA.new(public_key_s, "password").private_decrypt(encrypted_data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment