Rust
Rust
Generating Random Password
See more PRNG Examples
Demonstrates how to generate random passwords.Chilkat Rust Downloads
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let _ = false;
let fortuna = chilkat::Prng::new();
// Set this equal to true if the generated password must include at least one digit (0-9)
let b_digit = true;
// Set this equal to true if the generated password must include both uppercase and lowercase chars.
let b_upper_and_lower = true;
// The generated password must contain one of the following non-alphanumeric chars.
let other_chars = "@#$%*".to_string();
// Exclude chars that appear similar to others:
let exclude_chars = "iIlLoO0".to_string();
// Generate 8-character passwords:
for i in 1..=10 {
println!("{}", fortuna.random_password(8, b_digit, b_upper_and_lower, &other_chars, &exclude_chars).unwrap_or_default());
}