Function random_manager::bytes

source ·
pub fn bytes(n: usize) -> Result<Vec<u8>, String>
Expand description

Generates a random string of length “n”.

Examples found in repository?
src/lib.rs (line 9)
8
9
10
11
12
13
14
15
pub fn string(n: usize) -> String {
    let bytes = bytes(n).unwrap();
    let mut d = bs58::encode(&bytes[..]).into_string();
    if n > 0 && d.len() > n {
        d.truncate(n);
    }
    d
}