View Full Version : JavaScript Code Generator

04-06-2007, 11:56 AM
I need to generate about 500, 8 character codes... Does anyone know of a JavaScript that can do this?

04-06-2007, 01:28 PM
// Array of possible values to write to the string;
char = new Array("1","2","3","4","5","6","7","8","9","0","a","b","c","d","e","f");
var stringOutput;
var j=0

do {
for(i=0; i<8; i++) {
var num = Math.floor((Math.random() * char.length))
document.write("<br />");
while (j != 5);

This will give you 5 random values that it picks from the array choices... this isnt very secure though, so if you intend to store generate sensitive data, i would suggest using a server-side language rather then javascript which is fully accessible to the user.

just substitute 5 for however many you need, then copy and paste to a text document and voila u have your sets