Sha256: a942d5cfedd6d4f86d014a2eadc9c7ad05bffd315d152b15d4761c45f924fb54
Contents?: true
Size: 716 Bytes
Versions: 1
Compression:
Stored size: 716 Bytes
Contents
require "bcrypt" require "passwd/version" require "passwd/errors" require "passwd/config" require "passwd/railtie" if defined?(Rails) class Passwd class << self def current @current ||= new end attr_writer :current end def initialize(conf = nil) @config = conf end def password_hashing(plain) BCrypt::Password.create(plain, cost: config.stretching.clamp(BCrypt::Engine::MIN_COST, BCrypt::Engine::MAX_COST)) end def load_password(hashed_password) BCrypt::Password.new(hashed_password) end def random(long = nil) Array.new(long || config.length) { config.characters[rand(config.characters.size)] }.join end def config @config ||= Config.new end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
passwd-0.4.0 | lib/passwd.rb |