From c05af970bf8e3300752e39f8d04ec20eb03e0a1f Mon Sep 17 00:00:00 2001 From: GRMrGecko Date: Thu, 18 Sep 2014 14:40:11 -0500 Subject: [PATCH] Added code to verify that zxcvbn was loaded before running and automatically runs when it is loaded. The user will see a zxcvbn loading message in the location where statistics are usually shown. --- code/index.php | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/code/index.php b/code/index.php index 9a85d89..c1b4858 100644 --- a/code/index.php +++ b/code/index.php @@ -137,10 +137,27 @@ Total count of hashed passwords in database is Estimated time for hackers to crack: "+result.crack_time_display+"
Estimated time for hackers to crack in seconds: "+result.crack_time); + if (typeof zxcvbn != "function") { + $("#password_stats").html("Loading zxcvbn..."); + if (loadingCheckTimer==null) { + loadingCheckTimer = setInterval(function() { + if (typeof zxcvbn == "function") { + var result = zxcvbn($("#password_field").val()); + $("#password_score").attr("class", "score_"+result.score); + $("#password_stats").html("Entropy: "+result.entropy+"
Estimated time for hackers to crack: "+result.crack_time_display+"
Estimated time for hackers to crack in seconds: "+result.crack_time); + clearInterval(loadingCheckTimer); + loadingCheckTimer = null; + } + }, 200); + } + } else { + var result = zxcvbn($(this).val()); + $("#password_score").attr("class", "score_"+result.score); + $("#password_stats").html("Entropy: "+result.entropy+"
Estimated time for hackers to crack: "+result.crack_time_display+"
Estimated time for hackers to crack in seconds: "+result.crack_time); + } $("#sha1_field").val(CryptoJS.SHA1($(this).val()).toString()); });