gem 'aescrypt'
bundle
gem install aescrypt==================================
password save in encrypted formateAdd On model:
before_save :encrypt_password
def encrypt_password
encrypted_data = AESCrypt.encrypt(self.password, ENV['ENCRYPT_KEY'])
self.password = encrypted_data
end=============================================Encrypting
encrypted_data = AESCrypt.encrypt(message, password)
message = AESCrypt.decrypt(encrypted_data, password)
=============================================On Controllerexit_password = []account.account_passwords.last(3).map(&:password).each do |encrypted_data|
my_password = AESCrypt.decrypt(encrypted_data, ENV['ENCRYPT_KEY'])
if my_password == create_params[:new_password]
exit_password << encrypted_data
end
end