随机产生用户密码(good),说明:通过随机产生密码,然后将密码EMail给注册用户,你可以确认用户的EMail填写是否正确。
说明:通过随机产生密码,然后将密码EMail给注册用户,你可以确认用户的EMail填写是否正确。自动产生的密码往往安全性更高,同时,你可以过滤那些无效的用户。
把下面的代码保存为random.asp文件:
复制代码代码如下:
<%
SubStrRandomize(strSeed)
Dimi,nSeed
nSeed=CLng(0)
Fori=1ToLen(strSeed)
nSeed=nSeedXor((256*((i-1)Mod4)*AscB(Mid(strSeed,i,1))))
Next
RandomizenSeed
EndSub
FunctionGeneratePassword(nLength)
Dimi,bMadeConsonant,c,nRnd
ConststrDoubleConsonants="bdfglmnpst"
ConststrConsonants="bcdfghklmnpqrstv"
ConststrVocal="aeiou"
GeneratePassword=""
bMadeConsonant=False
Fori=0TonLength
nRnd=Rnd
IfGeneratePassword<>""AND(bMadeConsonant<>True)AND(nRnd<0.15)Then
c=Mid(strDoubleConsonants,Int(Len(strDoubleConsonants)*Rnd+1),1)
c=c&c
i=i+1
bMadeConsonant=True
Else
If(bMadeConsonant<>True)And(nRnd<0.95)Then
c=Mid(strConsonants,Int(Len(strConsonants)*Rnd+1),1)
bMadeConsonant=True
Else
c=Mid(strVocal,Int(Len(strVocal)*Rnd+1),1)
bMadeConsonant=False
EndIf
EndIf
GeneratePassword=GeneratePassword&c
Next
IfLen(GeneratePassword)>nLengthThen
GeneratePassword=Left(GeneratePassword,nLength)