3 个版本 (破坏性更新)
0.3.0 | 2020 年 8 月 31 日 |
---|---|
0.2.0 | 2020 年 8 月 27 日 |
0.1.0 | 2020 年 8 月 27 日 |
#537 在 身份验证
5,004 每月下载量
用于 fakedata_generator
30KB
364 行
passt
"足够好"的密码生成器 ¯\(ツ)/¯
passt
是一个“零依赖”的随机字符串生成器,可用于在终端或您的应用程序中生成密码。
零依赖吗?
passt
仅依赖于 Rust 标准库,即
std::fs::文件
std::io::读取
以及 CLI 部分
std::env
std::process::exit
没有其他 Crates。
唯一的其他“依赖”是 /dev/urandom
,从中读取随机整数以生成随机值。所以“零依赖”可能有点夸大。 😬
支持的操作系统
*nix
所有支持 GNU/Linux / *nix 系统的都应该得到支持,只要它们有 /dev/urandom
。仅在 MacOS 和 Ubuntu 上进行了测试。
Windows 支持
对于 Windows,file:/dev/urandom
已读取,但此功能尚未进行测试。它可能或可能不会正常工作。 🤷♀️ 欢迎帮助 Windows 支持!
用法:库
使用标准字符集
这意味着可能的字符是
a-zA-Z0-9
如果不包含特殊字符a-zA-Z0-9
和!§$%&/()=?´-_.,:;#'+*<>°^
如果包含特殊字符
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));
}
指定自定义字符集
这允许您使用不同的可能字符集。
fn my_custom_set() {
// Create password only from random chars "acefhjlnprtvxz13579"
Pass::random_password_with_custom_set(16, "acefhjlnprtvxz13579")
}
用法:CLI
安装
使用 cargo
安装
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"
没有特殊字符
$ passt -l 32
OgHFnTrSH5liCPhkrfbHdfhSWFwGGAPA
包含特殊字符
$ passt -l 16 -s
D#§2§RgI0Ou°F#
自定义字符集 甚至包括表情符号!
$ passt -l 16 -chars "🛹🥗🌈🦔🕶🤳🎮"
🌈🎮🎮🎮🤳🥗🎮🌈🎮🎮🎮🎮🤳🎮🕶🕶
$ passt -l 4 -chars "1234"
1341
创建多个密码
$ passt -l 4 -n 12
Bw9a
I0CP
obhV
wpmT
0tMu
h2NG
AzGd
D3jb
FmrT
mlsX
UdiJ
NbAr
限制
由于字符的随机提取较弱,最好在字符集中有重复。请看以下示例
passt -l 4 -chars "10"
0000
对于两个字符,最后一个字符总是被选中。为了随机性,向集合中添加更多字符。
passt -l 4 -chars "1010"
0100
为什么叫 "passt"
"passt" 是一个德语单词,当某事“没问题”时可以说。因为这个工具在生成随机字符串作为密码时表现“没问题”,所以我找到了这个名字很合适。
许可
passt
主要在 MIT 许可证和 Apache 许可证(版本 2.0)的条款下分发。
有关详细信息,请参阅 LICENSE-APACHE 和 LICENSE-MIT。