Random string

Results 1 to 2 of 2

Thread: Random string

  1. #1
    Join Date
    Dec 1969

    Default Random string

    Hello,<BR> Is there any way of generating a random string in VBScript or ASP?<BR><BR>Thanks in advance.

  2. #2
    Join Date
    Dec 1969

    Default Take a look at...

    http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=114<BR><BR>It allows you to "shuffle" even arrays of strings, so you could have it pick a random ordering of any number of small strings. Then you just do a JOIN on the array to get a single string from the array.<BR><BR>But if all you need is a password string that is randomly generated:<BR><BR>&#060;%<BR>&#039; *you* specify set of characters to use in password:<BR>chars = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789"<BR>password = ""<BR>Randomize<BR>For i = 1 To 10 &#039; or however long you want the password to be!<BR>&nbsp; &nbsp; password = password & Mid( chars, 1+Int(Rnd * Len(chars)), 1 )<BR>Next<BR>%&#062;<BR><BR>Notice that I left the letters "I" and "0" and the numbers "1" and "0" out of the list of characters, to avoid confusion between them. You can do that or not, as you please. You can use just alphabetic characters. Whatever. You control it.<BR><BR>

Posting Permissions

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