fugadalcontrollo/views/password.pug
2018-08-11 01:41:17 +02:00

32 lines
1,009 B
Text

extends layout
block content
p.
Bla bla bla qui devi scegliere una buona password
input#password(type="password", name="password")
p#crackTime
p#feedback
p#sequence
a#vinto(style="visibility: hidden") vinto
script(src="/js/zxcvbn.js")
script.
var crackTime = document.getElementById('crackTime')
var feedback = document.getElementById('feedback')
var sequence = document.getElementById('sequence')
var vinto = document.getElementById('vinto')
document.getElementById('password').oninput = function(ev, t) {
var ret = zxcvbn(this.value)
console.log(ret)
crackTime.innerHTML = 'A craccarla ci metto circa ' + ret.crack_times_display.offline_slow_hashing_1e4_per_second;
feedback.innerHTML = ret.feedback.suggestions.join(', ')
sequence.innerHTML = ret.sequence.map(s => s.pattern).join(' ,')
if (ret.score === 4){
vinto.style.visibility = 'visible';
} else {
vinto.style.visibility = 'hidden';
}
}