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
https://github.com/RubyCrypto/rbnacl#installation
brew install libsodium
pkg install libsodium
apt install libsodium-dev
gem install master_crypt
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
master_key = "Very secure & random master k3y"
encrypted_data = "...."
master_crypt = MasterCrypt.new(master_key)
plaintext = master_crypt.master_key_decrypt(encrypted_data)
secret_keys = ["array", "of", "secret", "keys"]
encrypted_data = MasterCrypt.encrypt(plaintext, secret_keys)
MasterCrypt.decrypt(encrypted_data, secret_keys[0])
bundle install
bundle exec rake
bundle exec guard