Skip to main content

encode_key

Function encode_key 

Source
pub fn encode_key(
    key: Vec<u8>,
    format: EncodingFormat,
) -> Result<String, String>
Expand description

Encodes the given key into the specified format (Hex or Base64).

§Examples

use genrs_lib::{encode_key, generate_key, EncodingFormat};

let key = generate_key(16);
let encoded_key = encode_key(key, EncodingFormat::Hex).unwrap();
println!("Hex encoded key: {}", encoded_key);

§Errors

Returns an error if the format is unsupported. However, this should never happen, as the format is now restricted to the EncodingFormat enum.