Skip to content

Instantly share code, notes, and snippets.

@VasylShevchenko
Forked from shmdt/Encryptable
Created November 7, 2019 10:11
Show Gist options
  • Save VasylShevchenko/ee6a4f7a7610b8bb02ef3a9e52affb45 to your computer and use it in GitHub Desktop.
Save VasylShevchenko/ee6a4f7a7610b8bb02ef3a9e52affb45 to your computer and use it in GitHub Desktop.
module Encryptable
def encrypt(key)
crypt.encrypt_and_sign(key)
end
def decrypt(key)
crypt.decrypt_and_verify(key)
end
private
def crypt
ActiveSupport::MessageEncryptor.new(Rails.application.credentials[:encryption_key])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment