Encryptoid uses OpenSSL to encrypt and decrypt data with a symmetric key.
Add this line to your application's Gemfile:
gem 'encryptoid', git: 'https://github.com/daftcode/encryptoid.git'
And then execute:
$ bundle
Set a salt
for AES encryption algorithm using a configuration block
Encryptoid.configure do |config|
config.aes_salt = '1234567890'
end
key = Encryptoid.random_key # generate random key
key = 'super_secret_key' # or pass own key
iv = OpenSSL::Cipher.new(Encryptoid::AES_ALGORITHM).random_iv
(remember to store your key
and iv
to be able to decrypt data)
Encryptoid.encrypt('private data', key: key, iv: iv)
Encryptoid.decrypt(encrypted_data, key: key, iv: iv)
Encryptoid.encrypt_file_in_chunks!('~/passwords.txt', chunk_size, key: key, iv: iv)
Encryptoid.decrypt_file('~/passwords.txt', key: key, iv: iv)
- Fork it ( https://github.com/[my-github-username]/encryptoid/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request