class Passwd
Constants
- VERSION
Attributes
current[W]
Public Class Methods
current()
click to toggle source
# File lib/passwd.rb, line 9 def current @current ||= new end
new(conf = nil)
click to toggle source
# File lib/passwd.rb, line 16 def initialize(conf = nil) @config = conf end
Public Instance Methods
config()
click to toggle source
# File lib/passwd.rb, line 32 def config @config ||= Config.new end
load_password(hashed_password)
click to toggle source
# File lib/passwd.rb, line 24 def load_password(hashed_password) BCrypt::Password.new(hashed_password) end
password_hashing(plain)
click to toggle source
# File lib/passwd.rb, line 20 def password_hashing(plain) BCrypt::Password.create(plain, cost: config.stretching.clamp(BCrypt::Engine::MIN_COST, BCrypt::Engine::MAX_COST)) end
random(long = nil)
click to toggle source
# File lib/passwd.rb, line 28 def random(long = nil) Array.new(long || config.length) { config.characters[rand(config.characters.size)] }.join end