Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

is this hash function any good?

Status
Not open for further replies.

silverspecv

Programmer
Oct 31, 2003
125
0
0
US
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.
 

Try the Squaring The Circle forum (forum1229) - they list maths and science as two of the topics covered, and I've recently got some good maths help there.

Hope this helps,
Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top