ICE Key Generator

From Valve Developer Community
Jump to: navigation, search

This is a simple HTML script that can be used to randomly generate an encryption code for use with Vice. Note that this does not generate a code for a specific game; its intent is for developers to get a completely random key to use for their own mod(s).

Source code

<script language="JavaScript" type="text/javascript">
var chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()_+-=[]{};/., ~`:<>?';
var l = chars.length-1;
document.write('<span style="font-size:5em;">');
for(var x=0;x<=7;x++)
{
	var chr = chars.charAt(Math.round(Math.random(new Date().getSeconds())*l));
	var out;
	switch(chr)
	{
		case '<':
			out = '&lt;';
			break;
		case '>':
			out = '&gt;';
			break;
		case '&':
			out = '&amp;';
			break;
		default:
			out = chr;
			break;
	}
	document.write(out);
}
document.write('</span>');
</script>

Alternative

Warning.pngWarning: See here Talk:ICE_Key_Generator

I'm not sure if Source/ICE support Unicode characters but i improved the script a little . . .

<script language="JavaScript" type="text/javascript">
var chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()_+-=[]{};/., ~`:<>?„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ';
var l = chars.length-1;
document.write('<span style="font-size:5em;">');
for(var x=0;x<=7;x++)
{
	var chr = chars.charAt(Math.round(Math.random(new Date().getSeconds())*l));
	var out;
	switch(chr)
	{
		case '<':
			out = '<';
			break;
		case '>':
			out = '>';
			break;
		case '&':
			out = '&';
			break;
		default:
			out = chr;
			break;
	}
	document.write(out);
}
document.write('</span>');
</script>
--Jenkins08 17:11, 7 April 2009 (UTC)