silverspecv
Programmer
Code:
function dohash(val) {
var result=1;
for(lp=0;lp<20;lp++) {
for(i=0;i<val.length;i++) {
result=result*val.charCodeAt(i);
if(result > 10000000000000) {
result=Math.ceil(result/5923);
}
}
}
return result;
}
This isn't really a JS question, more of a crypto question, but I don't see a forum for that, so here it is
I couldn't find any simple scripts for download, so I made one up.. basically, it uses ascii values and keeps multiplying over and over to generate large numbers, and if it goes over 10000000000000, it divides by 5923 (a prime number I picked at random.. not sure if there's any benefit or not), and then use CEIL method to truncate everything after the decimal and keep looping.. the truncate part is what I believe makes this a true one-way hash.. I run the loop 20 times, so the number grows and truncates several times...
but I'm not cryptographer.. Is there any problem here that jumps out any anyone?
BTW, in case you're wondering what's the point, the password scheme protects a function that adds restricted options to a dropdown list, and then the password does revalidate again using server-side script after submitting the form.