Skip to content
A Ruby encryption library compatible with the CFMX_COMPAT standard used in ColdFusion
Ruby
Find file
Latest commit d24a0b1 @jamesjoshuahill jamesjoshuahill Merge pull request #4 from globaldev/bump-ruby-version
Bump ruby patch version 1.9.3-p547
Failed to load latest commit information.
lib better nil handling, new rspec expect syntax
spec better nil handling, new rspec expect syntax
.gitignore
.ruby-version Bump ruby patch version 1.9.3-p547
Gemfile initial commit
Gemfile.lock Record Gemfile.lock for all specs passing
LICENSE.txt initial commit
README.md Add GH syntax highlighting to code samples
Rakefile initial commit
cfmx_compat.gemspec correct license

README.md

CFMX_COMPAT

Ruby implementation of the CFMX_COMPAT algorithm within ColdFusion. This will allow you to encrypt and decrypt strings using the CFMX_COMPAT algorithm.

The ColdFusion encrypt() and decrypt() functions also encode the result after encryption and automatically decode before decryption. This gem applies the same encoding and decoding behaviours as ColdFusion.

  • Base64: the Base64 algorithm, as specified by IETF RFC 2045.
  • Hex: the characters A-F0-9 represent the hexadecimal byte values.
  • UU: the UUEncode algorithm (DEFAULT).

The Ruby implementation here is translated from one found in Railo and a C# implementation of that.

Installation

Add this line to your application's Gemfile:

gem 'cfmx_compat'

And then execute:

$ bundle

Or install it yourself as:

$ gem install cfmx_compat

Usage

In Ruby, using this gem:

key = "secretkey"
plain = "plain text value"

encrypted = CfmxCompat.encrypt(plain, key)
decrypted = CfmxCompat.decrypt(encrypted, key)
plain == decrypted # true

encrypted = CfmxCompat.encrypt(plain, key, "uu")
decrypted = CfmxCompat.decrypt(encrypted, key, "uu")
plain == decrypted # true

encrypted = CfmxCompat.encrypt(plain, key, "hex")
decrypted = CfmxCompat.decrypt(encrypted, key, "hex")
plain == decrypted # true

encrypted = CfmxCompat.encrypt(plain, key, "base64")
decrypted = CfmxCompat.decrypt(encrypted, key, "base64")
plain == decrypted # true

Is the same as this in ColdFusion:

<cfscript>
key = "secretkey";
plain = "plain text value";

encrypted = encrypt(plain, key);
decrypted = decrypt(encrypted, key);
decrypted == plain; // true

encrypted = encrypt(plain, key, "CFMX_COMPAT", "uu");
decrypted = decrypt(encrypted, key, "CFMX_COMPAT", "uu");
decrypted == plain; // true

encrypted = encrypt(plain, key, "CFMX_COMPAT", "hex");
decrypted = decrypt(encrypted, key, "CFMX_COMPAT", "hex");
decrypted == plain; // true

encrypted = encrypt(plain, key, "CFMX_COMPAT", "base64");
decrypted = decrypt(encrypted, key, "CFMX_COMPAT", "base64");
decrypted == plain; // true
</cfscript>

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

License

Copyright © 2013 Global Personals Ltd.

This library is released under the LGPL license as detailed in the LICENSE.txt file that should be distributed with this library; the source code is freely available.

Global Personals Ltd have kindly agreed to the release of this software under the license terms above.

Something went wrong with that request. Please try again.