Project

encrypted

0.0
No commit activity in last 3 years
No release in over 3 years
Rijndael encryption with cbc. More Coming soon.
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.6
~> 10.0
 Project Readme

Encrypted

Ruby on Rails gem for encryption and decryption with Rijndael algorithm and CBC.

Key size options: 128, 192 and 256 bits Block size options: 128, 192 and 256 bits

AES is version of Rijndael with 128 bits block size. Hence, to encrypt/decrypt with AES standard choose any key size but 128 bits block size.

Installation

Add this line to your application's Gemfile:

gem 'encrypted'

And then execute:

$ bundle

Or install it yourself as:

$ gem install encrypted

Usage

Mode needs to be supplied when instantiating Encrypted::Ciph. Mode consists of desirable key length and block length in "keysize-blocksize" format. "256-128" implies key size of 256 bits and block size of 128 bits.

Encryption

    encrypt_this = "This is seriously confidential message."
    cipher = Encrypted::Ciph.new("256-256")
    key = "xvxvxvxxvxvxvxvxvxvxvxvxvxvxvxvx" # 256 bits / 8 = 32 bytes
    iv = "nmnmnmnmnmnmnmnmnmnmjkjkhjhjhjgh"  # 256 bits / 8 = 32 bytes
    cipher.key = key
    cipher.iv = iv
    encrypted_text = cipher.encrypt(encrypt_this)

Decryption

    decrypt_this = encrypted_text               #from above
    decipher = Encrypted::Ciph.new("256-256")
    cipher.key = "xvxvxvxxvxvxvxvxvxvxvxvxvxvxvxvx"     #key used above to encrypt
    cipher.iv = "nmnmnmnmnmnmnmnmnmnmjkjkhjhjhjgh"      #initialization vector used above
    decrypted_text = cipher.decrypt(decrypt_this)
"decrypted_text => 'This is some seriously confidential message.'"

Key and IV generation helper

To automatically generate and assign right size of random key and iv bytes while encrypting.

    encrypt_this = "This is seriously confidential message. Let me generate stuff for ya."
    cipher = Encrypted::Ciph.new("256-128")
    key = cipher.generate_key                    # Sets and returns 32 bytes long string
    iv = cipher.generate_iv                      # Sets and returns 16 bytes long string
    encrypted_text = cipher.encrypt(encrypt_this)
    

Contributing

  1. Fork it ( https://github.com/getaasciesh/encrypted/fork )
  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 a new Pull Request