forked from digininja/pipal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Work in progress to check for special characters used
- Loading branch information
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# encoding: utf-8 | ||
# | ||
# Work in progress to count special characters used across all passwords | ||
# | ||
|
||
# Find out what our base path is | ||
base_path = File.expand_path(File.dirname(__FILE__)) | ||
require File.join(base_path, '../horizbar.rb') | ||
register_checker("Special_Checker") | ||
|
||
class Special_Checker < Checker | ||
@list = {} | ||
|
||
def initialize | ||
super | ||
@list = {} | ||
end | ||
|
||
def process_word (word, extras = nil) | ||
word.each_char do |letter| | ||
if letter !~ /[a-z 0-9]/i | ||
if not @list.has_key? letter | ||
@list[letter] = 0 | ||
end | ||
@list[letter] += 1 | ||
end | ||
end | ||
@total_words_processed += 1 | ||
end | ||
|
||
def get_results() | ||
ret_str = "Special Checker\n" | ||
ret_str +="===============\n" | ||
disp = false | ||
|
||
(@list.sort do |x,y| (x[1] <=> y[1]) * -1 end).each do |special_data| | ||
unless special_data[1] == 0 | ||
disp = true | ||
ret_str << "#{special_data[0]} = #{special_data[1].to_s} (#{((special_data[1].to_f/@total_words_processed) * 100).round(2).to_s}%)\n" | ||
end | ||
end | ||
unless disp | ||
ret_str << "None found\n" | ||
end | ||
|
||
return ret_str | ||
end | ||
end |