Sub StrRandomize(strSeed)
Dim i, nSeed
nSeed = CLng(0)
For i = 1 To Len(strSeed)
nSeed = nSeed Xor ((256 * ((i - 1) Mod 4) * AscB(Mid(strSeed, i, 1))))
Next
'Randomiser
Randomize nSeed
End Sub
'--GeneratePassword(nLength)
'--Generates friendly passwords for remembering and pronounciation
Function GeneratePassword(nLength)
Dim i, bMadeConsonant, c, nRnd
'You may adjust the below constants to include local,
'eg. scandinavian characters. This way your passwords
'will not be limited to latin characters.
Const strDoubleConsonants = "bdfglmnpst"
Const strConsonants = "bcdfghklmnpqrstv"
Const strVocal = "aeiou"
GeneratePassword = ""
bMadeConsonant = False
For i = 0 To nLength
'Get a random number number between 0 and 1
nRnd = Rnd
'Simple or double consonant, or a new vocal?
'Does not start with a double consonant
'15% or less chance for the next letter being a double consonant
If GeneratePassword <> "" AND (bMadeConsonant <> True) AND (nRnd < 0.15) Then
'double consonant
c = Mid(strDoubleConsonants, Int(Len(strDoubleConsonants) * Rnd + 1), 1)
'response.write int(Len(strDoubleConsonants) * Rnd + 1)
'response.write "<br>"
c = c & c
i = i + 1
bMadeConsonant = True
Else
'80% or less chance for the next letter being a consonant,
'depending on wether the last letter was a consonant or not.
If (bMadeConsonant <> True) And (nRnd < 0.95) Then
'Simple consonant
c = Mid(strConsonants, Int(Len(strConsonants) * Rnd + 1), 1)
bMadeConsonant = True
'5% or more chance for the next letter being a vocal. 100% if last
'letter was a consonant - theoreticaly speaking...
Else
'If last one was a consonant, make vocal
c = Mid(strVocal,Int(Len(strVocal) * Rnd + 1), 1)
bMadeConsonant = False
End If
End If
'Add letter
GeneratePassword = GeneratePassword & c
Next
'Is the password long enough, or perhaps too long?
If Len(GeneratePassword) > nLength Then
GeneratePassword = Left(GeneratePassword, nLength)
End If
End Function
StrRandomize CStr(Now) & CStr(Rnd)
<%=strPassword%>
Const LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Const SYMBOLS = "~!@#$%^&*()_+-={}|[]\:"";'<>?,./"
Also and it's not important but I forgot a ' Second symbol comment between lines 22 and 23.
Const LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Const SYMBOLS = "~!@#$%^&*()_+-={}|[]\:"";'<>?,./"
Dim strPassword As String
Dim intIndex As Integer
Randomize
' Generate the password string making the 1st character a letter
strPassword = Mid(LETTERS, Int((26) * Rnd + 1), 1) & " "
' Randomly generate the 2nd through 6th characters.
' Second letter
intIndex = Int((5) * Rnd + 2)
Do Until Mid$(strPassword, intIndex, 1) = " "
intIndex = Int((5) * Rnd + 2)
Loop
strPassword = Left$(strPassword, intIndex - 1) & Mid(LETTERS, Int((26) * Rnd + 1), 1) & Mid$(strPassword, intIndex + 1)
' First symbol
intIndex = Int((5) * Rnd + 2)
Do Until Mid$(strPassword, intIndex, 1) = " "
intIndex = Int((5) * Rnd + 2)
Loop
strPassword = Left$(strPassword, intIndex - 1) & Mid(SYMBOLS, Int((31) * Rnd + 1), 1) & Mid$(strPassword, intIndex + 1)
Do Until Mid$(strPassword, intIndex, 1) = " "
intIndex = Int((5) * Rnd + 2)
Loop
strPassword = Left$(strPassword, intIndex - 1) & Mid(SYMBOLS, Int((31) * Rnd + 1), 1) & Mid$(strPassword, intIndex + 1)
' First number
Do Until Mid$(strPassword, intIndex, 1) = " "
intIndex = Int((5) * Rnd + 2)
Loop
strPassword = Left$(strPassword, intIndex - 1) & Int((10) * Rnd) & Mid$(strPassword, intIndex + 1)
' Second number
Do Until Mid$(strPassword, intIndex, 1) = " "
intIndex = Int((5) * Rnd + 2)
Loop
strPassword = Left$(strPassword, intIndex - 1) & Int((10) * Rnd) & Mid$(strPassword, intIndex + 1)
MsgBox strPassword
Dim strPassword
Dim intIndex
<html>
<head>
<!--#include file="../../includes/bdot/scripts.asp"-->
<meta charset="utf-8">
<title></title>
<script language="vbscript" runat="server">
Const LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Const SYMBOLS = "~!@#$%^&*()_+-={}|[]\:"";'<>?,./"
Dim strPassword
Dim intIndex
Randomize
' Generate the password string making the 1st character a letter
strPassword = Mid(LETTERS, Int((26) * Rnd + 1), 1) & " "
' Randomly generate the 2nd through 6th characters.
' Second letter
intIndex = Int((5) * Rnd + 2)
Do Until Mid(strPassword, intIndex, 1) = " "
intIndex = Int((5) * Rnd + 2)
Loop
strPassword = Left(strPassword, intIndex - 1) & Mid(LETTERS, Int((26) * Rnd + 1), 1) & Mid(strPassword, intIndex + 1)
' First symbol
intIndex = Int((5) * Rnd + 2)
Do Until Mid(strPassword, intIndex, 1) = " "
intIndex = Int((5) * Rnd + 2)
Loop
strPassword = Left(strPassword, intIndex - 1) & Mid(SYMBOLS, Int((31) * Rnd + 1), 1) & Mid(strPassword, intIndex + 1)
Do Until Mid(strPassword, intIndex, 1) = " "
intIndex = Int((5) * Rnd + 2)
Loop
strPassword = Left(strPassword, intIndex - 1) & Mid(SYMBOLS, Int((31) * Rnd + 1), 1) & Mid(strPassword, intIndex + 1)
' First number
Do Until Mid(strPassword, intIndex, 1) = " "
intIndex = Int((5) * Rnd + 2)
Loop
strPassword = Left(strPassword, intIndex - 1) & Int((10) * Rnd) & Mid(strPassword, intIndex + 1)
' Second number
Do Until Mid(strPassword, intIndex, 1) = " "
intIndex = Int((5) * Rnd + 2)
Loop
strPassword = Left(strPassword, intIndex - 1) & Int((10) * Rnd) & Mid(strPassword, intIndex + 1)
</script>
</head>
<body>
<p>password = <%=strPassword%></p>
</body>
Open in new window