WordPress.org

Make WordPress Core

Ticket #21737: 21737.zxcvbn-rot13.3.diff

File 21737.zxcvbn-rot13.3.diff, 2.0 KB (added by duck_, 8 years ago)
  • init.coffee

    diff --git a/init.coffee b/init.coffee
    index cbf922b..01f0ca0 100644
    a b zxcvbn = (password, user_inputs) -> 
    4848    for i in [0...user_inputs.length]
    4949      # update ranked_user_inputs_dict.
    5050      # i+1 instead of i b/c rank starts at 1.
    51       ranked_user_inputs_dict[user_inputs[i].toLowerCase()] = i + 1
     51      ranked_user_inputs_dict[rot_13(user_inputs[i].toLowerCase())] = i + 1
    5252  matches = omnimatch password
    5353  result = minimum_entropy_match_sequence password, matches
    5454  result.calc_time = time() - start
  • matching.coffee

    diff --git a/matching.coffee b/matching.coffee
    index 2d104e7..b961fb8 100644
    a b  
    11
     2rot_13 = (str) ->
     3  str.replace /[a-zA-Z]/g, (c) ->
     4    String.fromCharCode (if ((if c <= "Z" then 90 else 122)) >= (c = c.charCodeAt(0) + 13) then c else c - 26)
     5
    26empty = (obj) -> (k for k of obj).length == 0
    37extend = (lst, lst2) -> lst.push.apply lst, lst2
    48translate = (string, chr_map) -> (chr_map[chr] or chr for chr in string.split('')).join('')
    dictionary_match = (password, ranked_dict) -> 
    2226  result = []
    2327  len = password.length
    2428  password_lower = password.toLowerCase()
     29  password_lower = rot_13(password_lower)
    2530  for i in [0...len]
    2631    for j in [i...len]
    2732      if password_lower[i..j] of ranked_dict
    dictionary_match = (password, ranked_dict) -> 
    3237          i: i
    3338          j: j
    3439          token: password[i..j]
    35           matched_word: word
     40          matched_word: rot_13(word)
    3641          rank: rank
    3742        )
    3843  result
  • scripts/build_frequency_lists.py

    diff --git a/scripts/build_frequency_lists.py b/scripts/build_frequency_lists.py
    index 015f795..aa256eb 100644
    a b def filter_ascii(lst): 
    145145    return [word for word in lst if all(ord(c) < 128 for c in word)]
    146146
    147147def to_js(lst, lst_name):
     148    lst = map(lambda x : codecs.encode(x, 'rot_13'), lst)
    148149    return 'var %s = %s;\n\n' % (lst_name, simplejson.dumps(lst))
    149150
    150151def main():