[][src]Function mkpasswd::generate

pub fn generate(alphabet: &[u8], length: usize) -> Result<Vec<u8>, Error>

Generates a length long password made of bytes from alphabet.

This function uses the cryptographically secure OsRng internally.

Also see generate_with_rng for more information.

Errors

See the error section of generate_with_rng.

Example

use mkpasswd::{generate, Password};

let password = generate(&Password, 10).unwrap();
// `Password` contains only valid UTF-8 characters
let password = String::from_utf8(password).unwrap();

assert_eq!(password.len(), 10);

println!("Your password: {}", password);