faqts : Computers : Programming : Languages : Asp : ASP/VBScript : Common Problems

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

8 of 9 people (89%) answered Yes
Recently 4 of 4 people (100%) answered Yes

Entry

How can I generate a random password?

Jul 11th, 2000 20:17
unknown unknown, Jason Monroe


You could start by having a look here:

http://www.4guysfromrolla.com/webtech/122999-1.shtml
http://www.4guysfromrolla.com/webtech/tips/t011100-1.shtml

Here's some code by Jason Monroe:

It will generate a password, excluding the letters ILO and the numbers 1 
and 0 since those can be confused with each other..

Beware the word wrap..


'**************************************************************
'* Get Random Password based on the Number of chars requested *
'**************************************************************
function GetPassword(intStrLength)
        dim x, GotRand, intRand, strOut

        Randomize

        for x = 1 to intStrLength
                Do Until GotRand = True
                        intRand = Int((90 - 48 + 1) * Rnd + 48)
                        ' 48 to 57 is for numbers
                                ' 65 to 90 is for uppercase
                        ' 97 to 122 is for lowercase
                        If InStr(1, "ABCDEFGH JK MN PQRSTUVWXYZ 
23456789",
Chr(intRand), 1) Then
                                GotRand = True
                        End If
                Loop
                strOut = strOut & Chr(intRand)
                GotRand = False
        next
        GetPassword = strOut
End Function



© 1999-2004 Synop Pty Ltd