Sha256: d421fbb1ba5d97a2c7d7cb313bb165657b41a8cb3701fed6ad391b31a78cd1d2
Contents?: true
Size: 914 Bytes
Versions: 2
Compression:
Stored size: 914 Bytes
Contents
require 'aes' module Devise module Encryptors # = AES # Uses the AES algorithm to encrypt passwords. class Aes256 < Base class << self # Returns a Base64 encrypted password where pepper is used for the key, # and the initialization_vector is randomly generated and prepended onto # encoded ciphertext def digest(password, stretches, salt, pepper) ::AES.encrypt(password, pepper, {:iv => salt}) end alias :encrypt :digest # Returns a base64 encoded salt def salt(stretches) ::AES.iv(:base_64) end # Returns the plaintext password where pepper is used for the key, # and the initialization_vector is read from the Base64 encoded ciphertext def decrypt(encrypted_password, pepper) ::AES.decrypt(encrypted_password, pepper) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
devise_aes_encryptable-0.2.3 | lib/encryptors/aes256.rb |
devise_aes_encryptable-0.2.2 | lib/encryptors/aes256.rb |