get_random_alphanumeric_string

Function get_random_alphanumeric_string 

Source
pub fn get_random_alphanumeric_string(len: usize) -> String
Expand description

Generate random String with alphanumeric(uppercase, lowercase & number) charset of len length

ยงExample

const GEN_ASCII_STR_CHARSET: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ\
        abcdefghijklmnopqrstuvwxyz\
        0123456789";
const PASSWORD_LEN: usize = 30;
let password = rust_utils::random::get_random_alphanumeric_string(PASSWORD_LEN);
assert_eq!(password.len(), PASSWORD_LEN);
for x in password.bytes() {
    assert!(GEN_ASCII_STR_CHARSET.contains(&x));
}