2012-07-21 7 views
8

का उपयोग करके मैं सही काम करने के लिए zxcvbn, Dropbox's password strength estimator प्राप्त करने का प्रयास कर रहा हूं ... लेकिन मुझे कुछ समस्याएं हैं!ड्रॉपबॉक्स के zxcvbn पासवर्ड ताकत अनुमानक

मैंने एसिंक्रोनस लोडर को शामिल किया है।

मेरा अगला समस्या .... कि मैं काफी जे एस पता नहीं है यह पता लगाने की कैसे वास्तव में इस बात का उपयोग करने के लिए है

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

यह है कि मैदान पर नजर रखने के कुछ प्रकार के रूप में प्रयोग किया जाता है?

मदद, मैं अभी भी सीख रहा हूँ जे एस/jQuery के लिए धन्यवाद ...

+0

जब से तुम जे एस के लिए नए हैं, यह एक jQuery पासवर्ड मीटर प्लगइन खोजने के लिए सबसे आसान हो सकता है, और उसके बाद सिर्फ इतना है कि प्लगइन वैश्विक समारोह है कि zxcvbn बनाता है उपयोग करने के लिए कॉन्फ़िगर करें। अद्भुत पासवर्ड ताकत चेकर के लिए –

+0

+1, इसे पसंद किया :) – sabithpocker

उत्तर

16
<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(result); 

करने के लिए:

$('#result').html("cracktime : " + result.crack_time); 
+0

बढ़िया! अब ... मान लीजिए कि मैं सिर्फ परिणाम.crack_time का उपयोग करना चाहता हूं, मैं HTML में div div में यह डिस्प्ले कैसे बना सकता हूं (मैं इसका उपयोग कैसे कर सकता हूं ... हाहा)? – Shackrock

+0

@Shackrock अद्यतन उत्तर – sabithpocker

+0

क्या किसी ने requ.js के साथ इसे आजमाया? – Xerri