Function generate

Source
pub fn generate(length: usize, charset: &[u8]) -> String
Expand description

Generates a random string of a specified length using a given character set.

§Arguments

  • length - The length of the generated string.
  • charset - A slice of bytes representing the character set to use for generating the string.

§Returns

A String containing randomly selected characters from the provided character set.

§Examples

use advanced_random_string::{charset, random_string};

let random_string = random_string::generate(10, charset::BASE62);
println!("Generated string: {}", random_string);

// Specify a custom charset
let charset = b"MY_CHARSET";
let random_string_with_custom_charset = random_string::generate(10, charset);
println!("Generated string: {}", random_string_with_custom_charset);