Jump to content
UBot Underground

Using Javascript to Generate a Random String


Recommended Posts

I'm trying to generate a random number to use for usernames so I don't end up with duplicate values and have to keep retrying to find a usable one. The following code will allow me to generate a random number based on my criteria if I load it up in an html page and then execute it.

 

How can I do the same thing in the standard version without having to navigate to a separate html page to host the script? I want to end up with a variable (var1) as a result. Any ideas?

 

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML>

<HEAD>

<TITLE> String Generator </TITLE>

<script type="text/javascript">

function randomString() {

var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";

var string_length = 12;

var randomstring = '';

for (var i=0; i<string_length; i++) {

var rnum = Math.floor(Math.random() * chars.length);

randomstring += chars.substring(rnum,rnum+1);

}

document.randform.randomfield.value = randomstring;

}

</script>

 

</HEAD>

 

<BODY>

<form name="randform">

<input type="button" value="Create Random String" onClick="randomString();">

 

<input type="text" name="randomfield" value="">

</form>

</BODY>

</HTML>

 

Dutch

Link to post
Share on other sites

True, but how can I use $rand to generate mixed alpha and numeric strings like:

 

yHcAlWfLyEQD

7la9pvQmQB6D

ED1gM7fpoXxb

Link to post
Share on other sites

Is $spin available in Standard version. If so you can use

 

{1|2|3|4|5|6|7|8|9|0}{1|2|3|4|5|6|7|8|9|0}{1|2|3|4|5|6|7|8|9|0}{1|2|3|4|5|6|7|8|9|0}{1|2|3|4|5|6|7|8|9|0}

Link to post
Share on other sites
  • 2 weeks later...

Kudos to Kreatus and BotBuddy for their help in this solution. Here's an updated Random String Generator for your enjoyment.

 

Notes:

 

Username and Password generator

 

Here is a complete list of available characters

{A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|1|2|3|4|5|6|7|8|9|0|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|~|!|@|#|$|%|^|&|*|(|)|_|+|:|"|?|>|<}

 

Some accounts do not allow anything other than a letter as the first character.

 

Carve out of the complete list any characters you don't want to use. Then concatanate the complete list together for each digit you want.

For example: If you want a username that is all capital letters and is 3 digits long your pre-spin string will be as follows:

{A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z}{A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z}{A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z}

 

UserName - 15 (A-Z, 0-9) - Copy this string and concatanate (add) 15 of them together

{A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|1|2|3|4|5|6|7|8|9|0}

 

 

Password - 12 chars - no special symbols {~|!|@|#|$|%|^|&|*|(|)|_|+|:|"|?|>|<}

Copy from the opening "{" to the closing "}" and concatanate them 12 times.

 

{A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|1|2|3|4|5|6|7|8|9|0|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z}

 

Thanks again for the active forum participation!

 

Dutch

Random String Generator.ubot

  • Like 1
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...