Skip to main content

generate_key

Function generate_key 

Source
pub fn generate_key(length: usize) -> Vec<u8> 
Expand description

Generates a random key of the given length in bytes.

§Examples

use genrs_lib::generate_key;

let key = generate_key(16);
assert_eq!(key.len(), 16);

This function fills a vector of the specified length with secure random bytes using the system’s entropy source.

§Panics

Will panic if the system’s entropy source is unavailable.

Refer to the encode_key function for encoding the generated key.