Click here to Skip to main content
15,895,709 members
Home / Discussions / Web Development
   

Web Development

 
AnswerRe: Will VB COM will do better than normal ASP ? Pin
andyharman22-Mar-07 2:05
professionalandyharman22-Mar-07 2:05 
Question[Architecture] Building a plugin system in a Web Application Pin
Giovanny Temgoua21-Mar-07 4:03
Giovanny Temgoua21-Mar-07 4:03 
AnswerRe: [Architecture] Building a plugin system in a Web Application Pin
Bradml22-Mar-07 13:11
Bradml22-Mar-07 13:11 
GeneralRe: [Architecture] Building a plugin system in a Web Application Pin
Giovanny Temgoua23-Mar-07 8:10
Giovanny Temgoua23-Mar-07 8:10 
QuestionRe: [Architecture] Building a plugin system in a Web Application Pin
Giovanny Temgoua24-Mar-07 23:17
Giovanny Temgoua24-Mar-07 23:17 
QuestionHow can I do paging in Datagrid through JavaScript? Pin
Deepak Kashyap20-Mar-07 20:31
Deepak Kashyap20-Mar-07 20:31 
AnswerRe: How can I do paging in Datagrid through JavaScript? Pin
Vasudevan Deepak Kumar22-Mar-07 6:14
Vasudevan Deepak Kumar22-Mar-07 6:14 
QuestionJavascript Password Generator Pin
fryguy.ca20-Mar-07 17:16
fryguy.ca20-Mar-07 17:16 
I have a JavaScript Password Generator I need a hand with. I wanted to add a verification of the master password field, Its added and is almost functional. The code is public source (the MD5 under the BSD license), help fix it and you can use it too.

I know my code sucks, I don't do JavaScript.
You'll see the code near the bottom for the form to verify the passwords and generate the concentrated MD5 of the master password and the site/resource fields. I cant get it to verify the passwords and generate the MD5.

<br />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br />
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><br />
	<head><br />
		<title><br />
			Password Generator <br />
		</title><br />
		<script language="JavaScript"><br />
		<br />
			/*<br />
			 * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message<br />
			 * Digest Algorithm, as defined in RFC 1321.<br />
			 * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.<br />
			 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet<br />
			 * Distributed under the BSD License<br />
			 * See http://pajhome.org.uk/crypt/md5 for more info.<br />
			 */<br />
			<br />
			/*<br />
			 * Configurable variables. You may need to tweak these to be compatible with<br />
			 * the server-side, but the defaults work in most cases.<br />
			 */<br />
			var hexcase = 0;  /* hex output format. 0 - lowercase; 1 - uppercase        */<br />
			var chrsz   = 8;  /* bits per input character. 8 - ASCII; 16 - Unicode      */<br />
			<br />
			/*<br />
			 * These are the functions you'll usually want to call<br />
			 * They take string arguments and return either hex or base-64 encoded strings<br />
			 */<br />
			function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}<br />
			<br />
			/*<br />
			 * Calculate the MD5 of an array of little-endian words, and a bit length<br />
			 */<br />
			function core_md5(x, len)<br />
			{<br />
				/* append padding */<br />
				x[len >> 5] |= 0x80 << ((len) % 32);<br />
				x[(((len + 64) >>> 9) << 4) + 14] = len;<br />
			<br />
				var a =  1732584193;<br />
				var b = -271733879;<br />
				var c = -1732584194;<br />
				var d =  271733878;<br />
			<br />
				for(var i = 0; i < x.length; i += 16)<br />
				{<br />
					var olda = a;<br />
					var oldb = b;<br />
					var oldc = c;<br />
					var oldd = d;<br />
			<br />
					a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);<br />
					d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);<br />
					c = md5_ff(c, d, a, b, x[i+ 2], 17,  606105819);<br />
					b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);<br />
					a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);<br />
					d = md5_ff(d, a, b, c, x[i+ 5], 12,  1200080426);<br />
					c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);<br />
					b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);<br />
					a = md5_ff(a, b, c, d, x[i+ 8], 7 ,  1770035416);<br />
					d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);<br />
					c = md5_ff(c, d, a, b, x[i+10], 17, -42063);<br />
					b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);<br />
					a = md5_ff(a, b, c, d, x[i+12], 7 ,  1804603682);<br />
					d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);<br />
					c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);<br />
					b = md5_ff(b, c, d, a, x[i+15], 22,  1236535329);<br />
			<br />
					a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);<br />
					d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);<br />
					c = md5_gg(c, d, a, b, x[i+11], 14,  643717713);<br />
					b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);<br />
					a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);<br />
					d = md5_gg(d, a, b, c, x[i+10], 9 ,  38016083);<br />
					c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);<br />
					b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);<br />
					a = md5_gg(a, b, c, d, x[i+ 9], 5 ,  568446438);<br />
					d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);<br />
					c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);<br />
					b = md5_gg(b, c, d, a, x[i+ 8], 20,  1163531501);<br />
					a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);<br />
					d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);<br />
					c = md5_gg(c, d, a, b, x[i+ 7], 14,  1735328473);<br />
					b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);<br />
			<br />
					a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);<br />
					d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);<br />
					c = md5_hh(c, d, a, b, x[i+11], 16,  1839030562);<br />
					b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);<br />
					a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);<br />
					d = md5_hh(d, a, b, c, x[i+ 4], 11,  1272893353);<br />
					c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);<br />
					b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);<br />
					a = md5_hh(a, b, c, d, x[i+13], 4 ,  681279174);<br />
					d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);<br />
					c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);<br />
					b = md5_hh(b, c, d, a, x[i+ 6], 23,  76029189);<br />
					a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);<br />
					d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);<br />
					c = md5_hh(c, d, a, b, x[i+15], 16,  530742520);<br />
					b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);<br />
			<br />
					a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);<br />
					d = md5_ii(d, a, b, c, x[i+ 7], 10,  1126891415);<br />
					c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);<br />
					b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);<br />
					a = md5_ii(a, b, c, d, x[i+12], 6 ,  1700485571);<br />
					d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);<br />
					c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);<br />
					b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);<br />
					a = md5_ii(a, b, c, d, x[i+ 8], 6 ,  1873313359);<br />
					d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);<br />
					c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);<br />
					b = md5_ii(b, c, d, a, x[i+13], 21,  1309151649);<br />
					a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);<br />
					d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);<br />
					c = md5_ii(c, d, a, b, x[i+ 2], 15,  718787259);<br />
					b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);<br />
			<br />
					a = safe_add(a, olda);<br />
					b = safe_add(b, oldb);<br />
					c = safe_add(c, oldc);<br />
					d = safe_add(d, oldd);<br />
				}<br />
				return Array(a, b, c, d);<br />
			<br />
			}<br />
			<br />
			/*<br />
			 * These functions implement the four basic operations the algorithm uses.<br />
			 */<br />
			function md5_cmn(q, a, b, x, s, t)<br />
			{<br />
				return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);<br />
			}<br />
			function md5_ff(a, b, c, d, x, s, t)<br />
			{<br />
				return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);<br />
			}<br />
			function md5_gg(a, b, c, d, x, s, t)<br />
			{<br />
				return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);<br />
			}<br />
			function md5_hh(a, b, c, d, x, s, t)<br />
			{<br />
				return md5_cmn(b ^ c ^ d, a, b, x, s, t);<br />
			}<br />
			function md5_ii(a, b, c, d, x, s, t)<br />
			{<br />
				return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);<br />
			}<br />
			<br />
			/*<br />
			 * Add integers, wrapping at 2^32. This uses 16-bit operations internally<br />
			 * to work around bugs in some JS interpreters.<br />
			 */<br />
			function safe_add(x, y)<br />
			{<br />
				var lsw = (x & 0xFFFF) + (y & 0xFFFF);<br />
				var msw = (x >> 16) + (y >> 16) + (lsw >> 16);<br />
				return (msw << 16) | (lsw & 0xFFFF);<br />
			}<br />
			<br />
			/*<br />
			 * Bitwise rotate a 32-bit number to the left.<br />
			 */<br />
			function bit_rol(num, cnt)<br />
			{<br />
				return (num << cnt) | (num >>> (32 - cnt));<br />
			}<br />
			<br />
			/*<br />
			 * Convert a string to an array of little-endian words<br />
			 * If chrsz is ASCII, characters >255 have their hi-byte silently ignored.<br />
			 */<br />
			function str2binl(str)<br />
			{<br />
				var bin = Array();<br />
				var mask = (1 << chrsz) - 1;<br />
				for(var i = 0; i < str.length * chrsz; i += chrsz)<br />
					bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);<br />
				return bin;<br />
			}<br />
			<br />
			/*<br />
			 * Convert an array of little-endian words to a hex string.<br />
			 */<br />
			function binl2hex(binarray)<br />
			{<br />
				var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";<br />
				var str = "";<br />
				for(var i = 0; i < binarray.length * 4; i++)<br />
				{<br />
					str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +<br />
								 hex_tab.charAt((binarray[i>>2] >> ((i%4)*8  )) & 0xF);<br />
				}<br />
				return str;<br />
			}<br />
		<br />
		</script><br />
	</head><br />
	<body><br />
<!-- Start of Master Password Verify and Submit Form --><br />
<script><br />
var fieldalias="Master Password"<br />
<br />
function verify(element1, element2){<br />
var passed=false<br />
if (element1.value==''){<br />
alert("Please fill out the "Master Password")<br />
element1.focus()<br />
}<br />
else if (element2.value==''){<br />
alert("Please verify the Master Password")<br />
element2.focus()<br />
}<br />
else if (element1.value!=element2.value){<br />
alert("The two Master Passwords do not match")<br />
element1.select()<br />
}<br />
else<br />
passed=true<br />
<br />
return passed<br />
<br />
}<br />
<br />
</script><br />
<!--Below is my bad code :-D --><br />
<form class="callout" name="f" onSubmit="return verify(this.master, this.vmaster);password.value = hex_md5(master.value + <br />
<br />
':' + site.value).substr(0,8);document.f.password.focus();document.f.password.select();return false"><br />
<br />
<table><br />
<tr><br />
<td>Your Master Password: <input name="master" type="password"></td><br />
<script language="JavaScript">document.f.master.focus()</script><br />
</tr><br />
<tr><br />
<td>Verify Master Password: <input name="vmaster" type="password"></td><br />
</tr><br />
<tr><br />
<td>Site/Resource Name: </td><br />
<td><input name="site" /></td><br />
</tr><br />
<tr><br />
<td colspan="2"><input type="submit" value="Generate"><br />
</td><br />
</tr><br />
<tr class="output"><br />
<td>Generated Password: </td><br />
<td><input name="password" /></td><br />
</tr><br />
</table><br />
</form><br />
</body><br />
</html>				<br />

AnswerRe: Javascript Password Generator Pin
Bradml20-Mar-07 22:50
Bradml20-Mar-07 22:50 
GeneralRe: Javascript Password Generator Pin
fryguy.ca21-Mar-07 10:40
fryguy.ca21-Mar-07 10:40 
GeneralRe: Javascript Password Generator Pin
Bradml22-Mar-07 13:13
Bradml22-Mar-07 13:13 
QuestionIIS ASP Encrypt Utility Pin
Vasudevan Deepak Kumar20-Mar-07 12:55
Vasudevan Deepak Kumar20-Mar-07 12:55 
QuestionC++ dll accessed by COld Fusion Pin
LCI20-Mar-07 8:08
LCI20-Mar-07 8:08 
QuestiongSoap dime attachments Pin
abac_mefisto20-Mar-07 5:23
abac_mefisto20-Mar-07 5:23 
QuestionJavascript, innerHTML and Firefox Pin
JoiSteingrims20-Mar-07 5:14
JoiSteingrims20-Mar-07 5:14 
AnswerRe: Javascript, innerHTML and Firefox Pin
Guffa20-Mar-07 10:07
Guffa20-Mar-07 10:07 
AnswerRe: Javascript, innerHTML and Firefox Pin
JoiSteingrims21-Mar-07 13:19
JoiSteingrims21-Mar-07 13:19 
QuestionStarting Application Pin
Navneet Hegde20-Mar-07 3:03
Navneet Hegde20-Mar-07 3:03 
AnswerRe: Starting Application Pin
Laxman Auti21-Mar-07 5:56
Laxman Auti21-Mar-07 5:56 
QuestionWindows Authentication Pin
nclauder20-Mar-07 2:48
nclauder20-Mar-07 2:48 
JokeRe: Windows Authentication Pin
Laxman Auti21-Mar-07 5:58
Laxman Auti21-Mar-07 5:58 
GeneralRe: Windows Authentication Pin
nclauder21-Mar-07 21:43
nclauder21-Mar-07 21:43 
GeneralRe: Windows Authentication Pin
Laxman Auti21-Mar-07 22:03
Laxman Auti21-Mar-07 22:03 
GeneralRe: Windows Authentication Pin
nclauder21-Mar-07 23:26
nclauder21-Mar-07 23:26 
Questioncalling session["id"] from javascript Pin
haytham_mohammad20-Mar-07 0:27
haytham_mohammad20-Mar-07 0:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.