#random-password #random-string #password-generator #generate #terminal #cli-tool #zero

bin+lib passt

passt is a cli tool and library to generate good-enough random passwords

3 releases (breaking)

0.3.0 Aug 31, 2020
0.2.0 Aug 27, 2020
0.1.0 Aug 27, 2020

#452 in Authentication

Download history 1117/week @ 2023-12-06 1257/week @ 2023-12-13 1493/week @ 2023-12-20 758/week @ 2023-12-27 1461/week @ 2024-01-03 1749/week @ 2024-01-10 1486/week @ 2024-01-17 1885/week @ 2024-01-24 1660/week @ 2024-01-31 2388/week @ 2024-02-07 2299/week @ 2024-02-14 1601/week @ 2024-02-21 1485/week @ 2024-02-28 1598/week @ 2024-03-06 1337/week @ 2024-03-13 941/week @ 2024-03-20

5,551 downloads per month
Used in fakedata_generator

MIT/Apache

30KB
364 lines

passt

The "good-enough" password generator ¯\(ツ)

"Passt logo"

passt is a "zero-dependency" random string generator that can be used to generate passwords in terminals or in your application.


Zero Dependencies?

passt only depends on Rust standard library, namely:

  • std::fs::File
  • std::io::Read

and additionally for the CLI part:

  • std::env
  • std::process::exit

and no other crates.

The only other "dependency" is /dev/urandom from which random ints are read to generate random values. So "zero-dependency" may be a bit of a stretch. 😬

Supported operating systems

*nix

All GNU/Linux / *nix systems should be supported as long as they have /dev/urandom. Only tested on MacOS and Ubuntu.

Windows Support

For Windows file:/dev/urandom is read but this is not yet tested. It may or may not work. 🤷‍♀️ Help with Windows support is appreciated!

Usage: library

Using the standard character set

This means possible characters are:

  • a-zA-Z0-9 if no special chars are included
  • a-zA-Z0-9 and !§$%&/()=?´-_.,:;#'+*<>°^ if special chars are included
use passt:Passt;

fn my_random_password() -> String {
    // Passt::random_password(length: i32, with_special_chars: Option<bool>) -> String {
    Passt::random_password(16, Some(false));
}

fn my_random_password_with_none() -> String {
    // Passt::random_password(length: i32, with_special_chars: Option<bool>) -> String {
    Passt::random_password(16, None);
}

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

Specify custom character set

This allows you to use a different set of possible characters.

fn my_custom_set() {
    // Create password only from random chars "acefhjlnprtvxz13579"
    Pass::random_password_with_custom_set(16, "acefhjlnprtvxz13579")
}

Usage: cli

Install

Install with cargo:

cargo install passt

Then use as described below

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"

No special characters

$ passt -l 32
OgHFnTrSH5liCPhkrfbHdfhSWFwGGAPA

Include special characters

$ passt -l 16 -s
D#§2§RgI0Ou°F#

Custom character set Even with emojis!

$ passt -l 16 -chars "🛹🥗🌈🦔🕶🤳🎮"
🌈🎮🎮🎮🤳🥗🎮🌈🎮🎮🎮🎮🤳🎮🕶🕶

$ passt -l 4 -chars "1234"
1341

Create multiple passwords

$ passt -l 4 -n 12
Bw9a
I0CP
obhV
wpmT
0tMu
h2NG
AzGd
D3jb
FmrT
mlsX
UdiJ
NbAr

Limitations

Because the random extraction of characters is weak it is better to have duplicates in the character set. See the following example:

passt -l 4 -chars "10"
0000

With two characters, the last char is always taken. For randomness, add more chars to the set.

passt -l 4 -chars "1010"
0100

Why the name "passt"

"passt" is a German word you can say if something is "okay". Since this tool is "okay" in generating random strings that can be used for passwords I found the name fitting.

License

passt is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE and LICENSE-MIT for details.

No runtime deps