+ function clearEntropyFeedback() {
+ DOM.entropyStrength.text("...");
+ DOM.entropyType.text("");
+ DOM.entropyWordCount.text("0");
+ DOM.entropyEventCount.text("0");
+ DOM.entropyBitsPerEvent.text("0");
+ DOM.entropyBits.text("0");
+ DOM.entropyFiltered.html(" ");
+ DOM.entropyBinary.html(" ");
+ }
+
+ function showEntropyFeedback(entropy) {
+ var strength = "extremely weak";
+ if (entropy.binaryStr.length >= 64) {
+ strength = "very weak";
+ }
+ if (entropy.binaryStr.length >= 96) {
+ strength = "weak";
+ }
+ if (entropy.binaryStr.length >= 128) {
+ strength = "strong";
+ }
+ if (entropy.binaryStr.length >= 160) {
+ strength = "very strong";
+ }
+ if (entropy.binaryStr.length >= 192) {
+ strength = "extremely strong";
+ }
+ // If time to crack is less than one day, and password is considered
+ // strong or better based on the number of bits, rename strength to
+ // 'easily cracked'.
+ var z = zxcvbn(entropy.cleanStr);
+ var timeToCrack = z.crack_times_seconds.offline_fast_hashing_1e10_per_second;
+ if (timeToCrack < 86400 && entropy.binaryStr.length >= 128) {
+ strength = "easily cracked";
+ if (z.feedback.warning != "") {
+ strength = strength + " - " + z.feedback.warning;
+ };
+ }
+ var bitsStr = entropy.binaryStr.length;
+ var wordCount = Math.floor(entropy.binaryStr.length / 32) * 3;
+ DOM.entropyFiltered.html(entropy.cleanHtml);
+ DOM.entropyType.text(entropy.base.str);
+ DOM.entropyStrength.text(strength);
+ DOM.entropyEventCount.text(entropy.base.ints.length);
+ DOM.entropyBits.text(bitsStr);
+ DOM.entropyWordCount.text(wordCount);
+ DOM.entropyBinary.text(entropy.binaryStr);
+ DOM.entropyBitsPerEvent.text(Math.log2(entropy.base.asInt).toFixed(2));