Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

claude

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

claude

  • 0.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Claude

Claude transparently encrypts and decrypts sensitive Active Record attributes. Nothing magical or fancy, just a simple OpenSSL::Cipher wrapper.

Installation

Add this line to your application's Gemfile:

gem 'claude'

And then execute:

bundle

Usage

Say, you have to store sensitive information in your application database. You can use OpenSSL::Cipher to manually encrypt the value with a secret on write, and decrypt it with the same secret when used throughout the code base. This may work for a single sensitive attribute, but it gets out of hand if you gotta do it regularly.

Claude wraps OpenSSL::Cipher and lets you transparently encrypt and decrypt the your application sensitive attributes, so you don't have to do it manually all the time.

Claude exposes the encrypt and attr_encrypt class macros to setup an attribute encryption.

class Card < ActiveRecord::Base
  encrypt :pin
end

>> card = Card.new(pin: "1234")
=> #<Card id: nil, encrypted_pin: "FNYLjh2q9tWcYH5lG0zkPQ==\n", encrypted_pin_iv: "e4E99V82noXFLHhCfcWwBw==\n">
>> card.pin
=> "1234"

The encrypted pin dynamic attribute is backed by two database columns. encrypted_pin and encrypted_pin_iv. You have to create them by a migration, before using Claude.

The default secret used to encrypt an attribute with is config.secret_token for Rails 3.2 and secrets.secret_key_base for Rails 4. You can use per attribute secret or a different global one by setting config.claude.secret to your likings. Changing it will invalidate all the current encryptions, so beware of that.

Read the ActiveRecord::Base.encrypt and ActiveRecord::Base.attr_encrypt API documentation for more information.

Why Claude?

The library is named after Claude Elwood Shannon. He is considered to be the father of the modern mathematical cryptography.

Why should you use it? Because it makes encryption simple. :-)

FAQs

Package last updated on 29 Aug 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc