simple_cookie

Function encode_cookie_advanced

Source
pub fn encode_cookie_advanced<'a>(
    key: SigningKey,
    nonce: Nonce,
    name: impl AsRef<[u8]>,
    value: impl AsRef<[u8]>,
    output: &'a mut [u8],
) -> Result<&'a str, OutputBufferWrongSize>
Expand description

Just like encode_cookie, but advanced.

This function supports running in a no_std environment without the rand crate. To securely produce cookies you must guarantee that the provided Nonce is filled with cryptographically secure random data and the signing key you provide abides by the requirements documented on the SigningKey type.

You can use the encoded_buffer_size function to get the required size of the output buffer.

The encoded value is always valid ASCII, so this function returns the output buffer as an &str so you can avoid calling str::from_utf8() yourself if that’s what you wanted.