Sample code for 30+ languages & platforms
Visual FoxPro

Generating Random Password

See more PRNG Examples

Demonstrates how to generate random passwords.

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loFortuna
LOCAL lnBDigit
LOCAL lnBUpperAndLower
LOCAL lcOtherChars
LOCAL lcExcludeChars
LOCAL i

lnSuccess = 0

* This example assumes the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.

lnSuccess = 0

loFortuna = CreateObject('Chilkat.Prng')

* Set this equal to 1 if the generated password must include at least one digit (0-9)
lnBDigit = 1

* Set this equal to 1 if the generated password must include both uppercase and lowercase chars.
lnBUpperAndLower = 1

* The generated password must contain one of the following non-alphanumeric chars.
lcOtherChars = "@#$%*"

* Exclude chars that appear similar to others:
lcExcludeChars = "iIlLoO0"

* Generate 8-character passwords:

FOR i = 1 TO 10
    ? loFortuna.RandomPassword(8,lnBDigit,lnBUpperAndLower,lcOtherChars,lcExcludeChars)
NEXT

RELEASE loFortuna