8

我正在尝试让Dropbox 的密码强度估计器 zxcvbn正常工作……但我遇到了一些问题!

我已经包含了异步加载器。

我的下一个问题是我对 JS 了解的不够多,无法弄清楚如何实际使用这个东西......

<input id="password" name="password" size="35" class="textInput required" type="password">

它在那个领域被用作某种监视器吗?

感谢您的帮助,我还在学习 JS/jQuery ......

4

1 回答 1

19
<input id="password" name="password" size="35" class="textInput required" type="password"/>
<div id="result">
Laaa laa laa...
</div>

$('#password').keyup(function() {
  var textValue = $(this).val();
  var result = zxcvbn(textValue);
  $('#result').html("cracktime : " + result.crack_time);
  //use this result as you like
    /*
    result.entropy            # bits

result.crack_time         # estimation of actual crack time, in seconds.

result.crack_time_display # same crack time, as a friendlier string:
                          # "instant", "6 minutes", "centuries", etc.

result.score              # [0,1,2,3,4] if crack time is less than
                          # [10**2, 10**4, 10**6, 10**8, Infinity].
                          # (useful for implementing a strength bar.)

result.match_sequence     # the list of patterns that zxcvbn based the
                          # entropy calculation on.

result.calculation_time   # how long it took to calculate an answer,
                          # in milliseconds. usually only a few ms.
    */
});

为你提琴,http://jsfiddle.net/MhZ4p/

将 traverse 函数替换为仅破解时间

traverse(result);

至:

$('#result').html("cracktime : " + result.crack_time);
于 2012-07-21T23:30:40.483 回答