S
Skeleton Man
Hi,
I came across the basic algorithmfor decrypting WS_FTP Pro 6 passwords as
follows, and I'm trying to reverse it to make an encryption function:
function ws_dec()
{
var str = prompt('Enter encrypted password (including PWD=):','');
var output = '';
passw=str.substring(37,str.length);
for (var i = 0; i<passw.length/2; i++){
var caracter=passw.substring(i*2,i*2+2);
var sal=str.substring(5+i,6+i);
var claro=parseInt("0x"+caracter) -i -1 - ((47+parseInt("0x"+sal))%57);
output = output +String.fromCharCode(claro);
}
document.getElementById('dec').innerHTML = 'Decrypted Password Is: ' +
output;
}
I understand 95% of what is happening in the above code, but this line
puzzles me:
var claro=parseInt("0x"+caracter) -i -1 - ((47+parseInt("0x"+sal))%57);
I realise the parseInt() is just converting a hex value to integer.. but I
don't get why it adds 47 to the number and mods it with 57.. How would I
reverse this line so it took the original ascii code for the character and
encrypted it ?
Regards,
Chris
I came across the basic algorithmfor decrypting WS_FTP Pro 6 passwords as
follows, and I'm trying to reverse it to make an encryption function:
function ws_dec()
{
var str = prompt('Enter encrypted password (including PWD=):','');
var output = '';
passw=str.substring(37,str.length);
for (var i = 0; i<passw.length/2; i++){
var caracter=passw.substring(i*2,i*2+2);
var sal=str.substring(5+i,6+i);
var claro=parseInt("0x"+caracter) -i -1 - ((47+parseInt("0x"+sal))%57);
output = output +String.fromCharCode(claro);
}
document.getElementById('dec').innerHTML = 'Decrypted Password Is: ' +
output;
}
I understand 95% of what is happening in the above code, but this line
puzzles me:
var claro=parseInt("0x"+caracter) -i -1 - ((47+parseInt("0x"+sal))%57);
I realise the parseInt() is just converting a hex value to integer.. but I
don't get why it adds 47 to the number and mods it with 57.. How would I
reverse this line so it took the original ascii code for the character and
encrypted it ?
Regards,
Chris