Sha256: 97efde151b70cfcb1afd71ce4a5136d04599341123cd49751c3c53b55353ecce

Contents?: true

Size: 1.99 KB

Versions: 1

Compression:

Stored size: 1.99 KB

Contents

= aes

An AES encrypt/decrypt gem built on top of OpenSSL.  Not as quick as FastAES but doesn't require building native extensions - also supports Base64 encoded input and output.

Usage:

 require 'aes'

 # Generate a random key
 key = AES.key
  => "290c3c5d812a4ba7ce33adf09598a462"
  
 # Encrypt a string.  Default output is base_64 encoded, init_vector and cipher_text are joined with "$"
 b64 = AES.encrypt("A super secret message", key)
  => "IJjbgbv/OvPIAf4R5qAWyg==$fy0v7JwRX4kyAWflgouQlt9XGmiDKvbQMRHmQ+vy1fA="

 # Same as above but minus the base64 encoding, init_vector and cipher_text are shoved into an array
 plain = AES.encrypt("A super secret message", key, {:format => :plain}) #
  => [";\202\222\306\376<\206\343\023\245\312\225\214KAm", 
      "C\343\023\323U~W>\023y\217\341\201\371\352\334\311^\307\352{\020 H(DVw\3224N\223"]

 # Generate a random initialization vector
 iv = AES.iv(:base_64)
  => "IJjbgbv/OvPIAf4R5qAWyg=="
 
 # Encrypt a string, with a provided key and init_vector.  
 b64_iv = AES.encrypt("A super secret message", key, {:iv => iv})
  => "IJjbgbv/OvPIAf4R5qAWyg==$fy0v7JwRX4kyAWflgouQlt9XGmiDKvbQMRHmQ+vy1fA="
 
 AES.decrypt(b64, key)
  => "A super secret message"
 
 AES.decrypt(plain, key, {:format => :plain})
  => "A super secret message" 

== Contributing to aes
 
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
* Fork the project
* Start a feature/bugfix branch
* Commit and push until you are happy with your contribution
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

== Copyright

Copyright (c) 2010 Carl Hicks. See LICENSE.txt for
further details.

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aes-0.4.0 README.rdoc