Class: UnixCrypt::Base
- Inherits:
-
Object
- Object
- UnixCrypt::Base
- Defined in:
- lib/unix_crypt.rb
Class Method Summary collapse
Class Method Details
.build(password, salt = nil, rounds = nil) ⇒ Object
16 17 18 19 20 |
# File 'lib/unix_crypt.rb', line 16 def self.build(password, salt = nil, rounds = nil) salt ||= generate_salt "$#{identifier}$#{salt}$#{hash(password, salt, rounds)}" end |
.generate_salt ⇒ Object
22 23 24 25 26 |
# File 'lib/unix_crypt.rb', line 22 def self.generate_salt # Generates a random salt using the same character set as the base64 encoding # used by the hash encoder. SecureRandom.base64(default_salt_length).gsub("=", "").tr("+", ".") end |