#42191 - 2003-09-03 09:42 AM
Re: Generate password with only letters and numbers?
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Oops.
The problem is caused by the way I've used RND(). Normally RND(ceiling) implementations return a random number which is between 0 and ceiling-1, in other words the modulo of ceiling, or in some cases between 1 and ceiling. KiXtart returns a value between 0 and ceiling, which is a little unusual.
In the password generator UDF this would occasionally cause it to read past the end of the $sSelectFrom string, adding a blank character.
The fixed version follows:
Function udfPWGen($iLength,Optional $sSeed) Dim $sTerminal,$sNonTerminal,$iIndex,$iSeed
$sTerminal=$sTerminal+"BCDFGHJKLMNPQRSTVWXYZ" $sTerminal=$sTerminal+"bcdfghjklmnpqrstvwxyz" $sNonTerminal="0123456789" For $iIndex=1 To Len($sSeed) $iSeed=$iSeed+Asc(SubStr($sSeed,$iIndex,1)) Next Srnd($iSeed*@monthno) For $iIndex=1 to $iLength $sSelectFrom=IIF($iIndex=1 OR $iIndex=$iLength,$sTerminal,$sTerminal+$sNonTerminal) $udfPWGen=$udfPWGEn+Cstr(Substr($sSelectFrom,(Rnd(Len($sSelectFrom)-1)+1),1)) Next EndFunction
|
Serves me right for not reading the manual properly.
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 1441 anonymous users online.
|
|
|