Results 1 to 2 of 2

Thread: JavaScript Code Generator

  1. #1
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default JavaScript Code Generator

    I need to generate about 500, 8 character codes... Does anyone know of a JavaScript that can do this?

  2. #2
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    Code:
    // 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.writeln(char[num]);
    	}
    	document.write("<br />");
    	j++;
    }
    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •