Sample code for 30+ languages & platforms
Xbase++

Generating Random Password

See more PRNG Examples

Demonstrates how to generate random passwords.

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oFortuna
LOCAL nBDigit
LOCAL nBUpperAndLower
LOCAL cOtherChars
LOCAL cExcludeChars
LOCAL i

nSuccess := 0

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

nSuccess := 0

oFortuna := CreateObject("Chilkat.Prng")

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

//  Set this equal to 1 if the generated password must include both uppercase and lowercase chars.
nBUpperAndLower := 1

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

//  Exclude chars that appear similar to others:
cExcludeChars := "iIlLoO0"

//  Generate 8-character passwords:

FOR i := 1 TO 10
    ? oFortuna:RandomPassword(8, nBDigit, nBUpperAndLower, cOtherChars, cExcludeChars)
NEXT

oFortuna:destroy()