mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
19 lines
558 B
Ruby
19 lines
558 B
Ruby
require "bcrypt"
|
|
|
|
module Devise
|
|
module Encryptors
|
|
# = BCrypt
|
|
# Uses the BCrypt hash algorithm to encrypt passwords.
|
|
class Bcrypt < Base
|
|
# Gererates a default password digest based on stretches, salt, pepper and the
|
|
# incoming password. We don't strech it ourselves since BCrypt does so internally.
|
|
def self.digest(password, stretches, salt, pepper)
|
|
::BCrypt::Engine.hash_secret([password, pepper].join, salt, stretches)
|
|
end
|
|
|
|
def self.salt
|
|
::BCrypt::Engine.generate_salt
|
|
end
|
|
end
|
|
end
|
|
end
|