Skip to content

Instantly share code, notes, and snippets.

@allanbatista
Created October 29, 2018 18:15
Show Gist options
  • Select an option

  • Save allanbatista/0d9f9f541ad4d948656f95d690cefd6d to your computer and use it in GitHub Desktop.

Select an option

Save allanbatista/0d9f9f541ad4d948656f95d690cefd6d to your computer and use it in GitHub Desktop.
Exemplo de encrypt de arquivo.
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