Forum Moderators: open
For example:
randomize
randomnumber=int(rnd*9999)+1
This will create a random number 4 digits in length. If you use that and combine it with other random characters (first three characters of a user last name), you can come up with some decent passwords.
You mentioned the password being the "primary key". I'm guessing you're referring to an Access/SQL database. If so, you'll have to deal with that part on your own.
Either way, I wouldn't use the password as the primary key.
[ranainside.com...]
However, if you already have an email address field in your table which enforced to be unique, why add an extra GUID field at all?
I can't imagine that maintaining state using a database is a good idea unless you are forced in to it (eg in a web cluster situation). Managing state from within memory is much faster.
'Hire a programmer' - Why do you even participate on a forum like this Iguana, if only to provide sarcastic replies?
----
Random -Pronouncable- Password
Include the following function in your page:
Function RandomPassword(Min, Max)
Dim Password
Dim AddConsonant
Dim Letter
Dim Length
Dim Index
Dim Random
Const DoubleConsonants = "cdfglmnprst"
Const SingleConsonants = "bcdfghjklmnprstv"
Const Vowels = "aeiou"
Randomize()
Length = Int(Rnd * (Max - (Min - 1))) + Min
While Len(Password) < Length
Random = Int(Rnd * 100)
If Not Password = "" And AddConsonant And Random < 10 Then
Index = Int(Rnd * Len(DoubleConsonants)) + 1
Letter = Mid(DoubleConsonants, Index, 1)
Password = Password & Letter & Letter
AddConsonant = False
ElseIf Not Password = "" And AddConsonant And Random < 90 Then
Index = Int(Rnd * Len(SingleConsonants)) + 1
Letter = Mid(SingleConsonants, Index, 1)
Password = Password & Letter
AddConsonant = False
Else
Index = Int(Rnd * Len(Vowels)) + 1
Letter = Mid(Vowels, Index, 1)
Password = Password & Letter
AddConsonant = True
End If
Wend
If Len(Password) > Max Then Password = Left(Password, Max)
RandomPassword = Password
End Function
Then call it with something like
Response.Write RandomPassword(7, 10)
or, more likely, as the value of a form field:
<form action="submit.asp" method="post">
<input type="text" name="username">
<input type="password" name="password" value="<%=RandomPassword(7, 10)%>">
</form>