class AttrEncrypter
Constants
- DIGEST_FORMAT
- VERSION
Public Class Methods
new(keychain)
click to toggle source
# File lib/attr_encrypter.rb, line 16 def initialize(keychain) @boxes = Boxes.new(keychain || "") end
Public Instance Methods
decrypt(digest)
click to toggle source
# File lib/attr_encrypter.rb, line 28 def decrypt(digest) segments = digest.match(DIGEST_FORMAT) version = segments[1].to_i encoded = segments[2] encrypted = Base64.decode64(encoded) @boxes[version].decrypt(encrypted) end
encrypt(raw)
click to toggle source
# File lib/attr_encrypter.rb, line 20 def encrypt(raw) version = @boxes.latest_version encrypted = @boxes[version].encrypt(raw) encoded = Base64.encode64(encrypted) "#{version}.#{encoded}" end