Created
February 23, 2018 15:23
-
-
Save jigneshkhokhani/e1c45115dd9d48be2f0f60210243ef5b to your computer and use it in GitHub Desktop.
[Encrypt/Decrypt] Load after decrypt and dump after encrypt in DB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# lib/encrypted_coder.rb | |
class EncryptedCoder | |
include Crypt | |
def load(value) | |
return unless value.present? | |
Marshal.load( | |
Crypt.decrypt( | |
Base64.decode64(value))) | |
end | |
def dump(value) | |
Base64.encode64( | |
Crypt.encrypt( | |
Marshal.dump(value))) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment