Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/devise/encryptable/encryptable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module Encryptors
autoload :RestfulAuthenticationSha1, 'devise/encryptable/encryptors/restful_authentication_sha1'
autoload :Sha1, 'devise/encryptable/encryptors/sha1'
autoload :Sha512, 'devise/encryptable/encryptors/sha512'
autoload :Pbkdf2, 'devise/encryptable/encryptors/pbkdf2'
end
end
end
Expand Down
19 changes: 19 additions & 0 deletions lib/devise/encryptable/encryptors/pbkdf2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
begin
require "pbkdf2"

module Devise
module Encryptable
module Encryptors
# = PBKDF2
# Uses the PBKDF2 algorithm to encrypt passwords.
class Pbkdf2 < Base
def self.digest(password, stretches, salt, pepper)
::PBKDF2.new(password: password, salt: "#{[salt].pack('H*')}#{pepper}", iterations: stretches, hash_function: 'sha1', key_length: 64).hex_string
end
end
end
end
end
rescue LoadError
# Need pbkdf2 library installed to use this encryptor
end