Code:
//salt = 2YOPB3AQCVUXMNRS97WE0IZD4KLFGHJ8165T
//key = user-entered key 5segment e.g. 12345
x=0
for (keyIndex=0 ; <5: ++){
for (saltIndex=0; <36 ; ++){
if (salt[saltIndex]== key[keyIndex]){
x = saltIndex+ 36*x
}
}
}
mod = x%divisor; // if 0 then GOOD! else goto BadCode
And if you do some math you'll see that You can reverse the algorithm for calculating x down to this mathematical expression://key = user-entered key 5segment e.g. 12345
x=0
for (keyIndex=0 ; <5: ++){
for (saltIndex=0; <36 ; ++){
if (salt[saltIndex]== key[keyIndex]){
x = saltIndex+ 36*x
}
}
}
mod = x%divisor; // if 0 then GOOD! else goto BadCode
// Let matches[] be an array containing the values of saltIndex where there is a match (in order). Then matches[0] is the first match and matches[n] is the nth (and last) match. Looking at the code, we see:
fn(1)= Match1
fn(2) = 36*fn(1)+ Match2
fn(3) = 36*fn(2)+ Match3
fn(4) = 36*fn(3) + Match4
Simplifying we can get x:
x = matches[n]*360+matches[n-1]*361+ ... + matches[0]*36n

and then you just check the mod!







News Items and General Discussion About EH-Net : Change is Coming to EH-Net!!





