Skip to content

Instantly share code, notes, and snippets.

@korczis
Last active Aug 29, 2015
Embed
What would you like to do?
Encrypted hash
require 'encrypted_strings'
class Hash
class << self
def encrypt(h, password = 'password')
res = {}
h.each do |k, v|
res[k] = v.encrypt(:symmetric, :password => password)
end
res
end
def decrypt(h, password = 'password')
res = {}
h.each do |k, v|
res[k] = v.decrypt(:symmetric, :password => password)
end
res
end
end
def encrypt(password = 'password')
Hash.encrypt(self, password)
end
def decrypt(password = 'password')
Hash.decrypt(self, password)
end
end
source 'https://rubygems.org'
gem 'encrypted_strings'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment