0.0
Low commit activity in last 3 years
A long-lived project that still receives updates
A small wrapper around OpenSSL for encrypting and obfuscating short values such as ids in URLs. Derives its key from a Rails application's secret_key_base, or from ENV["SECRET_KEY_BASE"] outside of Rails.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 3.0
>= 1.13, < 5
>= 12.0, < 14

Runtime

>= 0.1
 Project Readme

BpObfuscate

CI

A simple wrapper around OpenSSL to easily encrypt/obfuscate data.

Inside a Rails application the key comes from the app's secret_key_base; outside of Rails it comes from ENV["SECRET_KEY_BASE"]. Works on Rails 4.1 through Rails 8.

Installation

Add this line to your application's Gemfile:

gem 'bp_obfuscate'

And then run bundle. Or install it yourself as:

$ gem install bp_obfuscate

Usage

token = Obfuscate.encrypt("user-42")   # => "rIMK7MWO-u-gLdi7qVKU8A=="
Obfuscate.decrypt(token)               # => "user-42"
Obfuscate.decrypt("garbage")           # => nil

decrypt returns nil instead of raising when it can't decrypt a value, so it's safe to call on untrusted input such as a URL parameter.

If no key is available, BpObfuscate::NoCipherKey is raised.

Development

Run bin/setup to install dependencies, bundle exec rspec for the tests, and bin/console for an interactive prompt.

To release a new version, update the version number in version.rb and run bundle exec rake release.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/rposborne/bp_obfuscate.

License

Available as open source under the terms of the MIT License.