Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Password generator
Message
 
 
To
20/07/2001 14:57:29
John Deupree
Long Term Care Authority
Tulsa, Oklahoma, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00533282
Message ID:
00533314
Views:
18
PMFJI, but this returns an Alpha-Numeric password. Chr(97) is the ASCII value for lower case A. Rand() gives you a random value between 0 and 1 (decimal) so you have to multiple it by something to get another range (in this case 0 to 25). Adding that number and 97 will give you a random letter between 'a' and 'z'.

>OK, I feel like I'm looking at a repeating # problem on an IQ test. I understand the concept, but why multiply by 25 if rand() is even or by 9 if not?
>
>Thanks
>
>John
>
>>FUNCTION GeneratePwd
>>LPARAMETERS pnLen && Length of Password - in your case 6
>>
>>rand(-1)
>>LOCAL lcPwd, lnRnd, lnCnt
>>
>>lcPwd = ""
>>FOR lnCnt = 1 TO pnLen
>> IF lnCnt = 1 OR mod(int(rand() * 100), 2) = 0 then
>> lnRnd = int(rand() * 25) + 97
>> ELSE
>> lnRnd = int(rand() * 9) + 48
>> ENDIF
>> lcPwd = lcPwd + chr(lnRnd)
>>ENDFOR
>>
>>RETURN lcPwd
>>ENDFUNC
>>
>>
>>HTH,
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform