Sample code for 30+ languages & platforms
DataFlex

Generating Random Password

See more PRNG Examples

Demonstrates how to generate random passwords.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoFortuna
    Boolean iBDigit
    Boolean iBUpperAndLower
    String sOtherChars
    String sExcludeChars
    Integer i
    String sTemp1

    Move False To iSuccess

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

    Move False To iSuccess

    Get Create (RefClass(cComChilkatPrng)) To hoFortuna
    If (Not(IsComObjectCreated(hoFortuna))) Begin
        Send CreateComObject of hoFortuna
    End

    // Set this equal to True if the generated password must include at least one digit (0-9)
    Move True To iBDigit

    // Set this equal to True if the generated password must include both uppercase and lowercase chars.
    Move True To iBUpperAndLower

    // The generated password must contain one of the following non-alphanumeric chars.
    Move "@#$%*" To sOtherChars

    // Exclude chars that appear similar to others:
    Move "iIlLoO0" To sExcludeChars

    // Generate 8-character passwords:

    For i From 1 To 10
        Get ComRandomPassword Of hoFortuna 8 iBDigit iBUpperAndLower sOtherChars sExcludeChars To sTemp1
        Showln sTemp1
    Loop



End_Procedure