1
Speak guys, I’m developing a numeric keyboard like the banks, in which the user selects a combination of numbers, but has to make the comparison with the password stored it, in bcrypt. The password is always 6 numeric digits (it’s easier, right ;) )
The keyboard:
<div class="password-keyboard">
<div class="row">
<div class="col-md-4">
<button class="btn btn-light btn-block" id="btnNumber_1" onclick="digitaCaracter('1')">1 ou 8</button>
<input type="hidden" id="btnNumberVal_1" name="btnNumber[]" value="1,8" />
</div>
<div class="col-md-4">
<button class="btn btn-light btn-block" id="btnNumber_2" onclick="digitaCaracter('2')">7 ou 2</button>
<input type="hidden" id="btnNumberVal_2" name="btnNumber[]" value="7,2" />
</div>
<div class="col-md-4">
<button class="btn btn-light btn-block" id="btnNumber_3" onclick="digitaCaracter('3')">5 ou 4</button>
<input type="hidden" id="btnNumberVal_3" name="btnNumber[]" value="5,4" />
</div>
<div class="col-md-4">
<button class="btn btn-light btn-block" id="btnNumber_4" onclick="digitaCaracter('4')">3 ou 6</button>
<input type="hidden" id="btnNumberVal_4" name="btnNumber[]" value="3,6" />
</div>
<div class="col-md-4">
<button class="btn btn-light btn-block" id="btnNumber_5" onclick="digitaCaracter('5')">9 ou 0</button>
<input type="hidden" id="btnNumberVal_5" name="btnNumber[]" value="9,0" />
</div>
<div class="col-md-4">
<a class="btn btn-light btn-block" onclick="removeCaracter()"><i class="fa fa-arrow-left"></i></a>
</div>
</div>
Every time you open the keyboard, the digits change:
for (var array=[],i=0;i<=9;++i) array[i]=i;
// http://stackoverflow.com/questions/962802#962890
var tmp, current, top = array.length;
if(top) while(--top) {
current = Math.floor(Math.random() * (top + 1));
tmp = array[current];
array[current] = array[top];
array[top] = tmp;
}
var nmbArr = array;
for (var i = 0; i<=4; i++) {
$('#btnNumber_'+(i+1)).html(nmbArr[i*2]+' ou '+nmbArr[(i*2)+1]);
$('#btnNumberVal_'+(i+1)).val(nmbArr[i*2]+','+nmbArr[(i*2)+1]);
}
The keyboard is working that is a beauty:
The one being sent is being captured as normal. The "problem" is how I will compare the combinations with the password of the user who is hashing bcrypt
Does anyone have any idea how I’m gonna validate these combinations? Will I have to check 64 times (2 6)???
I was trying so far with recursiveness. But I couldn’t. It’s really hard.
– Andrei Coelho
Anyway, congratulations on the code.
– Andrei Coelho