Function hash_derive_key_context

Source
pub fn hash_derive_key_context(context: &str) -> ContextKey
Expand description

Hash a derive_key context string and return a ContextKey.

The only valid uses for the returned ContextKey are Hasher::new_from_context_key and Mode::DeriveKeyMaterial (together with the merge subtree functions).

ยงExample

use blake3::Hasher;
use blake3::hazmat::HasherExt;

let context_key = blake3::hazmat::hash_derive_key_context("foo");
let mut hasher = Hasher::new_from_context_key(&context_key);
hasher.update(b"bar");
let derived_key = *hasher.finalize().as_bytes();

assert_eq!(derived_key, blake3::derive_key("foo", b"bar"));