diff --git a/data-scripts/build_frequency_lists.py b/data-scripts/build_frequency_lists.py
index cd1d1d5..0e2a2f4 100755
|
a
|
b
|
def filter_frequency_lists(freq_lists): |
| 117 | 117 | return result |
| 118 | 118 | |
| 119 | 119 | def to_kv(lst, lst_name): |
| | 120 | lst = map(lambda x : codecs.encode(x, 'rot_13'), lst) |
| 120 | 121 | val = '"%s".split(",")' % ','.join(lst) |
| 121 | 122 | return '%s: %s' % (lst_name, val) |
| 122 | 123 | |
diff --git a/src/main.coffee b/src/main.coffee
index 79f125b..ddd3c41 100644
|
a
|
b
|
feedback = require './feedback' |
| 5 | 5 | |
| 6 | 6 | time = -> (new Date()).getTime() |
| 7 | 7 | |
| | 8 | rot_13 = (str) -> |
| | 9 | str.replace /[a-zA-Z]/g, (c) -> |
| | 10 | String.fromCharCode (if ((if c <= "Z" then 90 else 122)) >= (c = c.charCodeAt(0) + 13) then c else c - 26) |
| | 11 | |
| 8 | 12 | zxcvbn = (password, user_inputs = []) -> |
| 9 | 13 | start = time() |
| 10 | 14 | # reset the user inputs matcher on a per-request basis to keep things stateless |
| 11 | 15 | sanitized_inputs = [] |
| 12 | 16 | for arg in user_inputs |
| 13 | 17 | if typeof arg in ["string", "number", "boolean"] |
| 14 | | sanitized_inputs.push arg.toString().toLowerCase() |
| | 18 | sanitized_inputs.push rot_13(arg.toString().toLowerCase()) |
| 15 | 19 | matching.set_user_input_dictionary sanitized_inputs |
| 16 | 20 | matches = matching.omnimatch password |
| 17 | 21 | result = scoring.most_guessable_match_sequence password, matches |
diff --git a/src/matching.coffee b/src/matching.coffee
index d85c145..cfb5a88 100644
|
a
|
b
|
frequency_lists = require('./frequency_lists') |
| 2 | 2 | adjacency_graphs = require('./adjacency_graphs') |
| 3 | 3 | scoring = require('./scoring') |
| 4 | 4 | |
| | 5 | rot_13 = (str) -> |
| | 6 | str.replace /[a-zA-Z]/g, (c) -> |
| | 7 | String.fromCharCode (if ((if c <= "Z" then 90 else 122)) >= (c = c.charCodeAt(0) + 13) then c else c - 26) |
| | 8 | |
| 5 | 9 | build_ranked_dict = (ordered_list) -> |
| 6 | 10 | result = {} |
| 7 | 11 | i = 1 # rank starts at 1, not 0 |
| … |
… |
matching = |
| 103 | 107 | matches = [] |
| 104 | 108 | len = password.length |
| 105 | 109 | password_lower = password.toLowerCase() |
| | 110 | password_lower = rot_13(password_lower) |
| 106 | 111 | for dictionary_name, ranked_dict of _ranked_dictionaries |
| 107 | 112 | for i in [0...len] |
| 108 | 113 | for j in [i...len] |
| … |
… |
matching = |
| 114 | 119 | i: i |
| 115 | 120 | j: j |
| 116 | 121 | token: password[i..j] |
| 117 | | matched_word: word |
| | 122 | matched_word: rot_13(word) |
| 118 | 123 | rank: rank |
| 119 | 124 | dictionary_name: dictionary_name |
| 120 | 125 | reversed: false |