Sha256: f354a860b5f580e1438ed5a979e0cc1561fb2978904c589a5f3e3bf53461e605
Contents?: true
Size: 819 Bytes
Versions: 1
Compression:
Stored size: 819 Bytes
Contents
require "digest" require "securerandom" require "passwd/version" require "passwd/errors" require "passwd/config" require "passwd/railtie" if defined?(Rails) class Passwd class << self def current @current ||= new end def current=(passwd) @current = passwd end end def initialize(conf = nil) @config = conf end def hashed_password(plain, salt) config.stretching.to_i.times.with_object([digest_class.hexdigest([plain, salt].join)]) { |_, pass| pass[0] = digest_class.hexdigest(pass[0]) }.first end def random(n = nil) Array.new(n || config.length) { config.characters[rand(config.characters.size)] }.join end def config @config ||= Config.new end private def digest_class Digest.const_get(config.algorithm.upcase) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
passwd-0.3.0 | lib/passwd.rb |