0.0
No commit activity in last 3 years
No release in over 3 years
Allows for encrypting a single piece of data with multiple keys which can each be used to decrypt it
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.18
~> 4.7.3
~> 0.13.0
~> 1.1
~> 13.0
~> 3.10

Runtime

~> 7.0
 Project Readme

Master Crypt

CircleCI Gem Version

Master Key is a gem for encrypting data with a master keying approach meaning you can encrypt data with multiple keys and then decrypt it any of them

This allows you to have a master key to decrypt the full set of data while also creating keys that can only decrypt a subset of data. These keys can then be safely distributed to relevant actors who will be only able to access their permitted data

You can encrypt data with as many keys as needed, all of which will be able to decrypt the data while only causing a small encrypted data size increase of 129 bytes for each extra key

Installation

Installing RbNaCl

https://github.com/RubyCrypto/rbnacl#installation

OS X users

brew install libsodium

FreeBSD users

pkg install libsodium

APT users

apt install libsodium-dev

Installing MasterCrypt

gem install master_crypt

Usage

Encrypting data with a master key

require "master_crypt"

master_key = "Very secure & random master k3y"
other_secret_key = "Another very secure & random other k3y"
plaintext = "Secret data..."
master_crypt = MasterCrypt.new(master_key)

encrypted_data = master_crypt.master_key_encrypt(plaintext, [other_secret_key])
# encrypted_data can be decrypted with either the master_key or other_secret_key

Decrypting data with a master key

master_key = "Very secure & random master k3y"
encrypted_data = "...."
master_crypt = MasterCrypt.new(master_key)

plaintext = master_crypt.master_key_decrypt(encrypted_data)

Encrypting data with an array of keys

secret_keys = ["array", "of", "secret", "keys"]
encrypted_data = MasterCrypt.encrypt(plaintext, secret_keys)

Decrypting data with a specific key

MasterCrypt.decrypt(encrypted_data, secret_keys[0])

Development

bundle install

Run all specs + standardrb

bundle exec rake

Run specs using guard

bundle exec guard