Skip to content
This repository has been archived by the owner. It is now read-only.
A simple and opinionated AES encrypt / decrypt Ruby gem that just works.
Branch: master
Clone or download
Gurpartap Merge pull request #2 from jameswomack/master
Gem failing without Base64 import on Ruby 2.0.0
Latest commit 43440a4 Mar 20, 2013

AESCrypt - Simple AES encryption / decryption for Ruby

AESCrypt is a simple to use, opinionated AES encryption / decryption Ruby gem that just works.

AESCrypt uses the AES-256-CBC cipher and encodes the encrypted data with Base64.

A corresponding gem to easily handle AES encryption / decryption in Objective-C is available at


Add this line to your application's Gemfile:

gem 'aescrypt'

And then execute:

$ bundle

Or install it yourself as:

$ gem install aescrypt


message = "top secret message"
password = "p4ssw0rd"


encrypted_data = AESCrypt.encrypt(message, password)


message = AESCrypt.decrypt(encrypted_data, password)

Advanced usage


encrypted_data = encrypt_data(data, key, iv, cipher_type)


decrypted_data = decrypt_data(encrypted_data, key, iv, cipher_type)

Corresponding usage in Objective-C

The AESCrypt Objective-C class, available at, understands what you're talking about in your Ruby code. The purpose of the Ruby gem and Objective-C class is to have something that works out of the box across the server (Ruby) and client (Objective-C). However, a standard encryption technique is implemented, which ensures that you can handle the data with any AES compatible library available across the web. So, you're not locked-in.

Here's how you would use the AESCrypt Objective-C class:

NSString *message = @"top secret message";
NSString *password = @"p4ssw0rd";


NSString *encryptedData = [AESCrypt encrypt:message password:password];


NSString *message = [AESCrypt decrypt:encryptedData password:password];

See the Objective-C class README at for more details.


Copyright (c) 2012 Gurpartap Singh

The encrypt_data and decrypt_data methods are Copyright (c) 2007 Brent Sowers and have been included in the gem with prior permission. Thanks Brent! :)

See LICENSE for license terms.


  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
You can’t perform that action at this time.