> Hvordan kan man let generere et kodeord bestående af tal og bogstaver på
> et
Google is your friend :)
Søg efter "asp random password", og et af de første resultater er:
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=6824&lngWId=4
For dem der ikke kan downloade siden, er koden:
Function RandomPW(myLength)
'These constant are the minimum and maximum length for random
'length passwords. Adjust these values to your needs.
Const minLength = 6
Const maxLength = 20
Dim X, Y, strPW
If myLength = 0 Then
Randomize
myLength = Int((maxLength * Rnd) + minLength)
End If
For X = 1 To myLength
'Randomize the type of this character
Y = Int((3 * Rnd) + 1) '(1) Numeric, (2) Uppercase, (3) Lowercase
Select Case Y
Case 1
'Numeric character
Randomize
strPW = strPW & CHR(Int((9 * Rnd) + 48))
Case 2
'Uppercase character
Randomize
strPW = strPW & CHR(Int((25 * Rnd) + 65))
Case 3
'Lowercase character
Randomize
strPW = strPW & CHR(Int((25 * Rnd) + 97))
End Select
Next
RandomPW = strPW
End Function