feat: add makepassword-rs

This commit is contained in:
2023-02-24 22:55:32 +08:00
parent 00e6b55d34
commit 91130596cb
3 changed files with 109 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
#!/usr/bin/env runrs
//! ```cargo
//! [dependencies]
//! rand = "0.8.5"
//! ```
use rand::RngCore;
const ENGLISH_LOWER: &'static str = "abcdefghijklmnopqrstuvwxyz";
const ENGLISH_UPPER: &'static str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const NUMBER: &'static str = "0123456789";
fn main() {
let str = ENGLISH_LOWER.to_string() + ENGLISH_UPPER + NUMBER;
let chars = str.chars().collect::<Vec<_>>();
let mut rng = rand::thread_rng();
let mut pass = String::new();
for _ in 0..18 {
pass.push(chars[rng.next_u32() as usize % chars.len()]);
}
println!("{}", pass);
}