No release in over a year
Add AES encryption support for Devise
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

~> 0.5.1
~> 4.9
 Project Readme

Devise Encryptable AES

Add AES encryption support for Devise

Table of Contents

  • Getting started
  • Configuration
  • Usage

Getting started

Add the following line to your Gemfile:

gem 'devise', '~> 4.9'
gem 'devise-encryptable', '~> 0.2.0'
gem 'devise_encryptable_aes', '~> 0.0.6'

Then run bundle install

Configuration

Add the encryptable module to your model:

class User < ActiveRecord::Base
  devise :database_authenticatable, :encryptable
end

And add the password_salt field to the database through a migration:

class DeviseCreateUsers < ActiveRecord::Migration
  def change
    add_column :users, :password_salt, :string
  end
end

Enable the AES encryptor in config/initializers/devise.rb

# Uncomment the generated pepper
config.pepper = "long random string"
# Enable the AES encryptor
config.encryptor = :aes256

Usage

Compare password

::Devise::Encryptable::Encryptors::Aes256.compare(encrypted_password, password, Devise.pepper)

Decrypt password

::Devise::Encryptable::Encryptors::Aes256.decrypt(encrypted_password, Devise.pepper)

If you get an error when using valid_password?, you can customize the valid_password? function to

  def valid_password?(password)
    ::Devise::Encryptable::Encryptors::Aes256.compare(encrypted_password, password, Devise.pepper)
  end