Project

cript

0.0
No commit activity in last 3 years
No release in over 3 years
Simple Encryption Tools for Ruby
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.3
>= 0
>= 0
 Project Readme

Cript

Simple Encryption Tools for Ruby

Gem Version Build Status

Installation

Add this line to your application's Gemfile:

gem 'cript'

And then execute:

$ bundle

Or install it yourself as:

$ gem install cript

Usage

Cript::Store

Cript::Store builds on PStore from the standard library, but encrypts the data it writes to the filesystem. By default it uses Cript::Simple to do the encryption.

require 'cript'
store = Cript::Store.new('/tmp/cript.store')
store.transaction do
  store[:secret] = "Super secret data!"
end

Cript::EHash

Cript::EHash is a convenience class that allows you to not explicitly declare transactions. You can treat it like you would normally treat a hash. Each message sent to the object automatically gets wrapped in a transaction block. Obviously, this will have performance implications.

Cript::Simple

Cript::Simple is a simple wrapper around the ruby openssl bindings. Once created, you can call encrypt or decrypt on it to encrypt or decrypt strings. It requires access to an an RSA private key. It can use only a public key if you're doing one-way encryption. If not provided at initialization, it will look in $HOME/.ssh/id_rsa and/or $HOME/.ssh/id_rsa.pub.

If you don't want to use your default ssh keys, you can pass in paths to a different key pair.

c1 = Cript::Simple.new(private_key_path: '/path/to/some/ssh_key')
plain = "More secret stuff!"
encrypted = c2.encrypt(plain)
decrypted = c2.decrypt(encrypted)

Or you can pass in the ssh keys as strings in PEM format:

c2 = Cript::Simple.new({
  private_key_content: "-----BEGIN RSA PRIVATE KEY-----\n3f4q..."
})
encrypted = c.encrypt("More secret stuff!")

You can use Cript::Simple from bash with the cript executable. Type cript --help after gem installation for usage.

TODO

  • gpg encryption option

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request