Dutch 4 Posted May 26, 2011 Report Share Posted May 26, 2011 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 Quote Link to post Share on other sites
Kreatus (Ubot Ninja) 422 Posted May 26, 2011 Report Share Posted May 26, 2011 Hi you can use $rand for that. here is the sample random.ubot Quote Link to post Share on other sites
Dutch 4 Posted May 26, 2011 Author Report Share Posted May 26, 2011 True, but how can I use $rand to generate mixed alpha and numeric strings like: yHcAlWfLyEQD7la9pvQmQB6DED1gM7fpoXxb Quote Link to post Share on other sites
Kreatus (Ubot Ninja) 422 Posted May 26, 2011 Report Share Posted May 26, 2011 check this http://ubotstudio.com/forum/index.php?/topic/6830-more-secure-passwords/page__view__findpost__p__33553 Quote Link to post Share on other sites
UBotBuddy 331 Posted May 26, 2011 Report Share Posted May 26, 2011 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} Quote Link to post Share on other sites
Dutch 4 Posted June 3, 2011 Author Report Share Posted June 3, 2011 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! DutchRandom String Generator.ubot 1 Quote Link to post Share on other sites
Kreatus (Ubot Ninja) 422 Posted June 3, 2011 Report Share Posted June 3, 2011 Nice one dutch for the effort! +1 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.