use rand::{thread_rng, Rng};
      use rand::distributions::Alphanumeric;
      
      fn main() {
        use rand::Rng;
        const CHARSET: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ\
          abcdefghijklmnopqrstuvwxyz\
          0123456789)(*&^%$#@!~";
        const PASSWORD_LEN: usize = 30;
        let mut rng = rand::thread_rng();
        let password: String = (0..PASSWORD_LEN)
        .map(|_| {
          let idx = rng.gen_range(0..CHARSET.len());
          CHARSET[idx] as char
        })
        .collect();
        println!("{:?}", password);
      }
      
      Rust language logo

      Generate passwords restricted

      Codiga's Rust Recipes

      from a set of user defined characters

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.