Sha256: 9a25b3d060612b62b19b142ed39df831ff1063f53f9942fca8b1a8e32bc77e7c
Contents?: true
Size: 1.17 KB
Versions: 2
Compression:
Stored size: 1.17 KB
Contents
# frozen_string_literal: true require_relative "zxcvbn/adjacency_graphs" require_relative "zxcvbn/frequency_lists" require_relative "zxcvbn/matching" require_relative "zxcvbn/scoring" require_relative "zxcvbn/time_estimates" require_relative "zxcvbn/feedback" require_relative "zxcvbn/version" module Zxcvbn class Error < StandardError; end def self.zxcvbn(password, user_inputs = []) start = (Time.now.to_f * 1000).to_i # reset the user inputs matcher on a per-request basis to keep things stateless sanitized_inputs = []; user_inputs.each do |arg| if arg.is_a?(String) || arg.is_a?(Numeric) || arg == true || arg == false sanitized_inputs << arg.to_s.downcase end end Matching.set_user_input_dictionary(sanitized_inputs) matches = Matching.omnimatch(password) result = Scoring.most_guessable_match_sequence(password, matches) result[:calc_time] = (Time.now.to_f * 1000).to_i - start attack_times = TimeEstimates.estimate_attack_times(result[:guesses]) attack_times.each do |prop, val| result[prop] = val end result[:feedback] = Feedback.get_feedback(result[:score], result[:sequence]) return result end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
zxcvbn-0.1.1 | lib/zxcvbn.rb |
zxcvbn-0.1.0 | lib/zxcvbn.rb |