Files
phy/blake3/index.html
Orion Kindel 0ce894e6b0 doc
2025-03-18 10:30:23 -05:00

61 lines
10 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="The official Rust implementation of the BLAKE3 cryptographic hash function."><title>blake3 - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="blake3" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.0 (9fc6b4312 2025-01-07)" data-channel="1.84.0" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../blake3/index.html">blake3</a><span class="version">1.5.4</span></h2></div><div class="sidebar-elems"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section id="rustdoc-toc"><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li><li><a href="#cargo-features" title="Cargo Features">Cargo Features</a></li></ul><h3><a href="#structs">Crate Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#constants" title="Constants">Constants</a></li><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Crate <span>blake3</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/blake3/lib.rs.html#1-1782">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>The official Rust implementation of the <a href="https://blake3.io">BLAKE3</a> cryptographic hash
function.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="comment">// Hash an input all at once.
</span><span class="kw">let </span>hash1 = blake3::hash(<span class="string">b"foobarbaz"</span>);
<span class="comment">// Hash an input incrementally.
</span><span class="kw">let </span><span class="kw-2">mut </span>hasher = blake3::Hasher::new();
hasher.update(<span class="string">b"foo"</span>);
hasher.update(<span class="string">b"bar"</span>);
hasher.update(<span class="string">b"baz"</span>);
<span class="kw">let </span>hash2 = hasher.finalize();
<span class="macro">assert_eq!</span>(hash1, hash2);
<span class="comment">// Extended output. OutputReader also implements Read and Seek.
</span><span class="kw">let </span><span class="kw-2">mut </span>output = [<span class="number">0</span>; <span class="number">1000</span>];
<span class="kw">let </span><span class="kw-2">mut </span>output_reader = hasher.finalize_xof();
output_reader.fill(<span class="kw-2">&amp;mut </span>output);
<span class="macro">assert_eq!</span>(hash1, output[..<span class="number">32</span>]);
<span class="comment">// Print a hash as hex.
</span><span class="macro">println!</span>(<span class="string">"{}"</span>, hash1);</code></pre></div>
<h2 id="cargo-features"><a class="doc-anchor" href="#cargo-features">§</a>Cargo Features</h2>
<p>The <code>std</code> feature (the only feature enabled by default) is required for
implementations of the <a href="https://doc.rust-lang.org/std/io/trait.Write.html"><code>Write</code></a> and <a href="https://doc.rust-lang.org/std/io/trait.Seek.html"><code>Seek</code></a> traits, the
<a href="struct.Hasher.html#method.update_reader" title="method blake3::Hasher::update_reader"><code>update_reader</code></a> helper method, and runtime CPU
feature detection on x86. If this feature is disabled, the only way to use
the x86 SIMD implementations is to enable the corresponding instruction sets
globally, with e.g. <code>RUSTFLAGS="-C target-cpu=native"</code>. The resulting binary
will not be portable to other machines.</p>
<p>The <code>rayon</code> feature (disabled by default, but enabled for <a href="https://docs.rs/">docs.rs</a>) adds
the <a href="Hasher::update_rayon"><code>update_rayon</code></a> and (in combination with <code>mmap</code>
below) <a href="Hasher::update_mmap_rayon"><code>update_mmap_rayon</code></a> methods, for
multithreaded hashing. However, even if this feature is enabled, all other
APIs remain single-threaded.</p>
<p>The <code>mmap</code> feature (disabled by default, but enabled for <a href="https://docs.rs/">docs.rs</a>) adds the
<a href="Hasher::update_mmap"><code>update_mmap</code></a> and (in combination with <code>rayon</code> above)
<a href="Hasher::update_mmap_rayon"><code>update_mmap_rayon</code></a> helper methods for
memory-mapped IO.</p>
<p>The <code>zeroize</code> feature (disabled by default, but enabled for <a href="https://docs.rs/">docs.rs</a>)
implements
<a href="https://docs.rs/zeroize/latest/zeroize/trait.Zeroize.html"><code>Zeroize</code></a> for
this crates types.</p>
<p>The <code>serde</code> feature (disabled by default, but enabled for <a href="https://docs.rs/">docs.rs</a>) implements
<a href="https://docs.rs/serde/latest/serde/trait.Serialize.html"><code>serde::Serialize</code></a> and
<a href="https://docs.rs/serde/latest/serde/trait.Deserialize.html"><code>serde::Deserialize</code></a>
for <a href="struct.Hash.html" title="struct blake3::Hash"><code>Hash</code></a>.</p>
<p>The NEON implementation is enabled by default for AArch64 but requires the
<code>neon</code> feature for other ARM targets. Not all ARMv7 CPUs support NEON, and
enabling this feature will produce a binary thats not portable to CPUs
without NEON support.</p>
<p>The <code>traits-preview</code> feature enables implementations of traits from the
RustCrypto <a href="https://crates.io/crates/digest"><code>digest</code></a> crate, and re-exports that crate as <code>traits::digest</code>.
However, the traits arent stable, and theyre expected to change in
incompatible ways before that crate reaches 1.0. For that reason, this crate
makes no SemVer guarantees for this feature, and callers who use it should
expect breaking changes between patch versions. (The “-preview” feature name
follows the conventions of the RustCrypto <a href="https://crates.io/crates/signature"><code>signature</code></a> crate.)</p>
</div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.Hash.html" title="struct blake3::Hash">Hash</a></div><div class="desc docblock-short">An output of the default size, 32 bytes, which provides constant-time
equality checking.</div></li><li><div class="item-name"><a class="struct" href="struct.Hasher.html" title="struct blake3::Hasher">Hasher</a></div><div class="desc docblock-short">An incremental hash state that can accept any number of writes.</div></li><li><div class="item-name"><a class="struct" href="struct.HexError.html" title="struct blake3::HexError">HexError</a></div><div class="desc docblock-short">The error type for <a href="struct.Hash.html#method.from_hex" title="associated function blake3::Hash::from_hex"><code>Hash::from_hex</code></a>.</div></li><li><div class="item-name"><a class="struct" href="struct.OutputReader.html" title="struct blake3::OutputReader">Output<wbr>Reader</a></div><div class="desc docblock-short">An incremental reader for extended output, returned by
<a href="struct.Hasher.html#method.finalize_xof"><code>Hasher::finalize_xof</code></a>.</div></li></ul><h2 id="constants" class="section-header">Constants<a href="#constants" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="constant" href="constant.KEY_LEN.html" title="constant blake3::KEY_LEN">KEY_LEN</a></div><div class="desc docblock-short">The number of bytes in a key, 32.</div></li><li><div class="item-name"><a class="constant" href="constant.OUT_LEN.html" title="constant blake3::OUT_LEN">OUT_LEN</a></div><div class="desc docblock-short">The number of bytes in a <a href="struct.Hash.html"><code>Hash</code></a>, 32.</div></li></ul><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="fn" href="fn.derive_key.html" title="fn blake3::derive_key">derive_<wbr>key</a></div><div class="desc docblock-short">The key derivation function.</div></li><li><div class="item-name"><a class="fn" href="fn.hash.html" title="fn blake3::hash">hash</a></div><div class="desc docblock-short">The default hash function.</div></li><li><div class="item-name"><a class="fn" href="fn.keyed_hash.html" title="fn blake3::keyed_hash">keyed_<wbr>hash</a></div><div class="desc docblock-short">The keyed hash function.</div></li></ul></section></div></main></body></html>