Class: Devise::Encryptors::Aes256

Inherits:
Base
  • Object
show all
Defined in:
lib/encryptors/aes256.rb

Overview

AES

Uses the AES algorithm to encrypt passwords.

Class Method Summary collapse

Class Method Details

.decrypt(encrypted_password, pepper) ⇒ Object

Returns the plaintext password where pepper is used for the key, and the initialization_vector is read from the Base64 encoded ciphertext



22
23
24
# File 'lib/encryptors/aes256.rb', line 22

def decrypt(encrypted_password, pepper)        
  ::AES.decrypt(encrypted_password, pepper)
end

.digest(password, stretches, salt, pepper) ⇒ Object Also known as: encrypt

Returns a Base64 encrypted password where pepper is used for the key, and the initialization_vector is randomly generated and prepended onto encoded ciphertext



12
13
14
# File 'lib/encryptors/aes256.rb', line 12

def digest(password, stretches, salt, pepper)
  ::AES.encrypt(password, pepper, {:iv => salt})
end

.salt(stretches) ⇒ Object

Returns a base64 encoded salt



17
18
19
# File 'lib/encryptors/aes256.rb', line 17

def salt(stretches)
  ::AES.iv(:base_64)
end