sekreti

Gem Version

sekreti is an easy-to use yet minimal Gem to encrypt and decrypt file. It is based upon OpenSSL and intends to be as easy as possible on usage. \ Sekreti currently supports AES-128-CBC and AES-256-CBC protocol.

Installation

Add this line to your application's Gemfile:

gem 'sekreti', '1.0.0'

And then execute:

$ bundle

Or install it yourself as:

$ gem install sekreti

Usage

From a Ruby file, basic steps are :

Encrypt a file

require "sekreti"

encrypt = sekreti::Crypt.new
encrypt.file = "./decrypted_file.txt"
encrypt.output_file = "./encrypted_output.txt"
encrypt.protocol = "AES-256-CBC" # is aes-128-cbc by default

# You must define an encryption key.
# Is 16 bytes long for aes-128-cbc
# Is 32 bytes long for aes-256-cbc
encrypt.key = "a" * 32 # a 16 bytes long encryption key for aes-128-cbc

# Validate that everything is ok 

encrypt.file? # true
encrypt.output_file? # true
encrypt.key? # true


# Encrypt the file
encrypt.status? # false
encrypt.encrypt! # returns true
encrypt.status? # true
encrypt.dump # Returns the whole state

Decrypt a file

require "sekreti"

decrypt = sekreti::Crypt.new
decrypt.file = "./encrypted_file.txt"
decrypt.output_file = "./decrypted_output.txt"
decrypt.key = "a" * 32

# Validate that everything is ok

decrypt.file? # true
decrypt.output_file? # true
decrypt.key? # true

# Decrypt the file
decrypt.status? # false
decrypt.decrypt! # returns true
decrypt.status? # true

# Dump the whole state 
decrypt.dump 

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

The documentation can be generated with Yard :

bundle exec rake doc

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/atilleh/sekreti. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the sekreti project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.