feat: add makepassword-rs
This commit is contained in:
25
makepassword-rs/src/main.rs
Normal file
25
makepassword-rs/src/main.rs
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user