Rust CLI and library to generate good-enough random strings and passwords

View source code on

passt is a CLI tool and library that can be used to generate random strings, e.g. for use as passwords. It is very “weak” in that it doesn’t use any “real” cryptography and should therefor not be used as an actual password generator.

You can use passt to generate random test input when testing software tho.

Up to date information can be found on GitHub

Usage: CLI


$ cargo install passt


USAGE: passt -l <int> [-s] [-chars "<str>"] [-n <int>]

-l      length of the generated password
-n      number of passwords to create (default: 1)
-s      use special characters
-chars  possible characters as a string, e.g. "abc012"

Usage: Library

Generate random string with default character sets:

function signature

Passt::random_password(length: i32, with_special_chars: Option<bool>) -> String

code example

use passt::Passt;

fn my_random_password() -> String {
    Passt::random_password(16, Some(false));

fn my_random_password_with_none() -> String {
    Passt::random_password(16, None);

fn my_random_password_with_special_chars() -> String {
    Passt::random_password(16, Some(true));

Use custom character set

fn my_custom_set() {
    Pass::random_password_with_custom_set(16, "acefhjlnprtvxz13579")

Like this?

This website contains no advertisement, no tracking, no paid articles, and no shady-things-whatsoever. It is just content, provided free of charge and with accessibility in mind.

If you would like to support me in providing content - and code - for free or if this page has helped you or your company, consider supporting me directly.

You can support me via:

A colorful image of me wearing my DIY mask. The image has a colorful glitch effect.

Kevin Gimbel

is a DevOps Engineer and avid (Video) Gamer. He’s also interested in Sci-Fi, Cyberpunk, and dystopian books.

Wearing a mask is a good idea!

You can find out more about me if you wish.