ASP VBScript function to generate random password
August 17th, 2007 by Denis GolovtsovSometime I have to work with ASP projects. I don’t like ASP. At first because it’s old technology which almost doesn’t use in new projects now and this experience won’t very helpful. Any way I’d like to present here one simple function that might help someone.
‘ Generate random password
‘
‘ @author Denis Golovtsov, http://goldenman.spb.ru/
‘ @param length integer - Tne length of generated password.
‘ @output string - Generated password.
‘
Public Function NewPassword(length)
Dim range,password
range = “0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ”
password = “”
Randomize
While length > 0
password = password & Mid(range, 1 + Int(Len(range) * Rnd), 1)
length = length - 1
Wend
NewPassword = password
End Function
I’m sure all are clear there and it doesn’t require additional comments.