Sample code for 30+ languages & platforms
Lianja

Generating Random Password

See more PRNG Examples

Demonstrates how to generate random passwords.

Chilkat Lianja Downloads

Lianja
llSuccess = .F.

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

llSuccess = .F.

loFortuna = createobject("CkPrng")

// Set this equal to .T. if the generated password must include at least one digit (0-9)
llBDigit = .T.

// Set this equal to .T. if the generated password must include both uppercase and lowercase chars.
llBUpperAndLower = .T.

// 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,llBDigit,llBUpperAndLower,lcOtherChars,lcExcludeChars)
next


release loFortuna