28 lines
19 KiB
HTML
28 lines
19 KiB
HTML
<!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="Pure Rust implementation of the SHA-1 cryptographic hash algorithm with optional hardware-specific optimizations."><title>sha1 - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.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"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="sha1" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../static.files/storage-e2aeef58.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.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]--><rustdoc-topbar><h2><a href="#">Crate sha1</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../sha1/index.html"><img src="https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg" alt="logo"></a><h2><a href="../sha1/index.html">sha1</a><span class="version">0.10.6</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="#-warning-cryptographically-broken-" title="🚨 Warning: Cryptographically Broken! 🚨">🚨 Warning: Cryptographically Broken! 🚨</a></li><li><a href="#usage" title="Usage">Usage</a></li><li><a href="#note-for-users-of-sha1-v06" title="Note for users of `sha1 v0.6`">Note for users of <code>sha1 v0.6</code></a></li></ul><h3><a href="#reexports">Crate Items</a></h3><ul class="block"><li><a href="#reexports" title="Re-exports">Re-exports</a></li><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#traits" title="Traits">Traits</a></li><li><a href="#types" title="Type Aliases">Type Aliases</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><h1>Crate <span>sha1</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/sha1/lib.rs.html#1-154">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Pure Rust implementation of the <a href="https://en.wikipedia.org/wiki/SHA-1">SHA-1</a> cryptographic hash algorithm
|
|
with optional hardware-specific optimizations.</p>
|
|
<h2 id="-warning-cryptographically-broken-"><a class="doc-anchor" href="#-warning-cryptographically-broken-">§</a>🚨 Warning: Cryptographically Broken! 🚨</h2>
|
|
<p>The SHA-1 hash function should be considered cryptographically broken and
|
|
unsuitable for further use in any security critical capacity, as it is
|
|
<a href="https://sha-mbles.github.io/">practically vulnerable to chosen-prefix collisions</a>.</p>
|
|
<p>We provide this crate for legacy interoperability purposes only.</p>
|
|
<h2 id="usage"><a class="doc-anchor" href="#usage">§</a>Usage</h2>
|
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>hex_literal::hex;
|
|
<span class="kw">use </span>sha1::{Sha1, Digest};
|
|
|
|
<span class="comment">// create a Sha1 object
|
|
</span><span class="kw">let </span><span class="kw-2">mut </span>hasher = Sha1::new();
|
|
|
|
<span class="comment">// process input message
|
|
</span>hasher.update(<span class="string">b"hello world"</span>);
|
|
|
|
<span class="comment">// acquire hash digest in the form of GenericArray,
|
|
// which in this case is equivalent to [u8; 20]
|
|
</span><span class="kw">let </span>result = hasher.finalize();
|
|
<span class="macro">assert_eq!</span>(result[..], <span class="macro">hex!</span>(<span class="string">"2aae6c35c94fcfb415dbe95f408b9ce91ee846ed"</span>));</code></pre></div>
|
|
<p>Also see <a href="https://github.com/RustCrypto/hashes">RustCrypto/hashes</a> readme.</p>
|
|
<h2 id="note-for-users-of-sha1-v06"><a class="doc-anchor" href="#note-for-users-of-sha1-v06">§</a>Note for users of <code>sha1 v0.6</code></h2>
|
|
<p>This crate has been transferred to the RustCrypto organization and uses
|
|
implementation previously published as the <code>sha-1</code> crate. The previous
|
|
zero dependencies version is now published as the <a href="https://github.com/mitsuhiko/sha1-smol/"><code>sha1_smol</code></a> crate.</p>
|
|
</div></details><h2 id="reexports" class="section-header">Re-exports<a href="#reexports" class="anchor">§</a></h2><dl class="item-table reexports"><dt id="reexport.digest"><code>pub use <a class="mod" href="../digest/index.html" title="mod digest">digest</a>;</code></dt></dl><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><dl class="item-table"><dt><a class="struct" href="struct.Sha1Core.html" title="struct sha1::Sha1Core">Sha1<wbr>Core</a></dt><dd>Core SHA-1 hasher state.</dd></dl><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><dl class="item-table"><dt><a class="trait" href="trait.Digest.html" title="trait sha1::Digest">Digest</a></dt><dd>Convenience wrapper trait covering functionality of cryptographic hash
|
|
functions with fixed output size.</dd></dl><h2 id="types" class="section-header">Type Aliases<a href="#types" class="anchor">§</a></h2><dl class="item-table"><dt><a class="type" href="type.Sha1.html" title="type sha1::Sha1">Sha1</a></dt><dd>SHA-1 hasher state.</dd></dl><script type="text/json" id="notable-traits-data">{"<CoreWrapper<T> as ExtendableOutput>::Reader":"<h3>Notable traits for <code><a class=\"struct\" href=\"../digest/core_api/wrapper/struct.CoreWrapper.html\" title=\"struct digest::core_api::wrapper::CoreWrapper\">CoreWrapper</a><T></code></h3><pre><code><div class=\"where\">impl<T> <a class=\"trait\" href=\"https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html\" title=\"trait std::io::Write\">Write</a> for <a class=\"struct\" href=\"../digest/core_api/wrapper/struct.CoreWrapper.html\" title=\"struct digest::core_api::wrapper::CoreWrapper\">CoreWrapper</a><T><div class=\"where\">where\n T: <a class=\"trait\" href=\"../digest/core_api/trait.BufferKindUser.html\" title=\"trait digest::core_api::BufferKindUser\">BufferKindUser</a> + <a class=\"trait\" href=\"../digest/core_api/trait.UpdateCore.html\" title=\"trait digest::core_api::UpdateCore\">UpdateCore</a>,\n <T as <a class=\"trait\" href=\"../crypto_common/trait.BlockSizeUser.html\" title=\"trait crypto_common::BlockSizeUser\">BlockSizeUser</a>>::<a class=\"associatedtype\" href=\"../crypto_common/trait.BlockSizeUser.html#associatedtype.BlockSize\" title=\"type crypto_common::BlockSizeUser::BlockSize\">BlockSize</a>: <a class=\"trait\" href=\"../typenum/type_operators/trait.IsLess.html\" title=\"trait typenum::type_operators::IsLess\">IsLess</a><<a class=\"struct\" href=\"../typenum/uint/struct.UInt.html\" title=\"struct typenum::uint::UInt\">UInt</a><<a class=\"struct\" href=\"../typenum/uint/struct.UInt.html\" title=\"struct typenum::uint::UInt\">UInt</a><<a class=\"struct\" href=\"../typenum/uint/struct.UInt.html\" title=\"struct typenum::uint::UInt\">UInt</a><<a class=\"struct\" href=\"../typenum/uint/struct.UInt.html\" title=\"struct typenum::uint::UInt\">UInt</a><<a class=\"struct\" href=\"../typenum/uint/struct.UInt.html\" title=\"struct typenum::uint::UInt\">UInt</a><<a class=\"struct\" href=\"../typenum/uint/struct.UInt.html\" title=\"struct typenum::uint::UInt\">UInt</a><<a class=\"struct\" href=\"../typenum/uint/struct.UInt.html\" title=\"struct typenum::uint::UInt\">UInt</a><<a class=\"struct\" href=\"../typenum/uint/struct.UInt.html\" title=\"struct typenum::uint::UInt\">UInt</a><<a class=\"struct\" href=\"../typenum/uint/struct.UInt.html\" title=\"struct typenum::uint::UInt\">UInt</a><<a class=\"struct\" href=\"../typenum/uint/struct.UTerm.html\" title=\"struct typenum::uint::UTerm\">UTerm</a>, <a class=\"struct\" href=\"../typenum/bit/struct.B1.html\" title=\"struct typenum::bit::B1\">B1</a>>, <a class=\"struct\" href=\"../typenum/bit/struct.B0.html\" title=\"struct typenum::bit::B0\">B0</a>>, <a class=\"struct\" href=\"../typenum/bit/struct.B0.html\" title=\"struct typenum::bit::B0\">B0</a>>, <a class=\"struct\" href=\"../typenum/bit/struct.B0.html\" title=\"struct typenum::bit::B0\">B0</a>>, <a class=\"struct\" href=\"../typenum/bit/struct.B0.html\" title=\"struct typenum::bit::B0\">B0</a>>, <a class=\"struct\" href=\"../typenum/bit/struct.B0.html\" title=\"struct typenum::bit::B0\">B0</a>>, <a class=\"struct\" href=\"../typenum/bit/struct.B0.html\" title=\"struct typenum::bit::B0\">B0</a>>, <a class=\"struct\" href=\"../typenum/bit/struct.B0.html\" title=\"struct typenum::bit::B0\">B0</a>>, <a class=\"struct\" href=\"../typenum/bit/struct.B0.html\" title=\"struct typenum::bit::B0\">B0</a>>>,\n <<T as <a class=\"trait\" href=\"../crypto_common/trait.BlockSizeUser.html\" title=\"trait crypto_common::BlockSizeUser\">BlockSizeUser</a>>::<a class=\"associatedtype\" href=\"../crypto_common/trait.BlockSizeUser.html#associatedtype.BlockSize\" title=\"type crypto_common::BlockSizeUser::BlockSize\">BlockSize</a> as <a class=\"trait\" href=\"../typenum/type_operators/trait.IsLess.html\" title=\"trait typenum::type_operators::IsLess\">IsLess</a><<a class=\"struct\" href=\"../typenum/uint/struct.UInt.html\" title=\"struct typenum::uint::UInt\">UInt</a><<a class=\"struct\" href=\"../typenum/uint/struct.UInt.html\" title=\"struct typenum::uint::UInt\">UInt</a><<a class=\"struct\" href=\"../typenum/uint/struct.UInt.html\" title=\"struct typenum::uint::UInt\">UInt</a><<a class=\"struct\" href=\"../typenum/uint/struct.UInt.html\" title=\"struct typenum::uint::UInt\">UInt</a><<a class=\"struct\" href=\"../typenum/uint/struct.UInt.html\" title=\"struct typenum::uint::UInt\">UInt</a><<a class=\"struct\" href=\"../typenum/uint/struct.UInt.html\" title=\"struct typenum::uint::UInt\">UInt</a><<a class=\"struct\" href=\"../typenum/uint/struct.UInt.html\" title=\"struct typenum::uint::UInt\">UInt</a><<a class=\"struct\" href=\"../typenum/uint/struct.UInt.html\" title=\"struct typenum::uint::UInt\">UInt</a><<a class=\"struct\" href=\"../typenum/uint/struct.UInt.html\" title=\"struct typenum::uint::UInt\">UInt</a><<a class=\"struct\" href=\"../typenum/uint/struct.UTerm.html\" title=\"struct typenum::uint::UTerm\">UTerm</a>, <a class=\"struct\" href=\"../typenum/bit/struct.B1.html\" title=\"struct typenum::bit::B1\">B1</a>>, <a class=\"struct\" href=\"../typenum/bit/struct.B0.html\" title=\"struct typenum::bit::B0\">B0</a>>, <a class=\"struct\" href=\"../typenum/bit/struct.B0.html\" title=\"struct typenum::bit::B0\">B0</a>>, <a class=\"struct\" href=\"../typenum/bit/struct.B0.html\" title=\"struct typenum::bit::B0\">B0</a>>, <a class=\"struct\" href=\"../typenum/bit/struct.B0.html\" title=\"struct typenum::bit::B0\">B0</a>>, <a class=\"struct\" href=\"../typenum/bit/struct.B0.html\" title=\"struct typenum::bit::B0\">B0</a>>, <a class=\"struct\" href=\"../typenum/bit/struct.B0.html\" title=\"struct typenum::bit::B0\">B0</a>>, <a class=\"struct\" href=\"../typenum/bit/struct.B0.html\" title=\"struct typenum::bit::B0\">B0</a>>, <a class=\"struct\" href=\"../typenum/bit/struct.B0.html\" title=\"struct typenum::bit::B0\">B0</a>>>>::<a class=\"associatedtype\" href=\"../typenum/type_operators/trait.IsLess.html#associatedtype.Output\" title=\"type typenum::type_operators::IsLess::Output\">Output</a>: <a class=\"trait\" href=\"../typenum/marker_traits/trait.NonZero.html\" title=\"trait typenum::marker_traits::NonZero\">NonZero</a>,</div></div>","CoreWrapper<T>":"<h3>Notable traits for <code><a class=\"struct\" href=\"../digest/core_api/wrapper/struct.CoreWrapper.html\" title=\"struct digest::core_api::wrapper::CoreWrapper\">CoreWrapper</a><T></code></h3><pre><code><div class=\"where\">impl<T> <a class=\"trait\" href=\"https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html\" title=\"trait std::io::Write\">Write</a> for <a class=\"struct\" href=\"../digest/core_api/wrapper/struct.CoreWrapper.html\" title=\"struct digest::core_api::wrapper::CoreWrapper\">CoreWrapper</a><T><div class=\"where\">where\n T: <a class=\"trait\" href=\"../digest/core_api/trait.BufferKindUser.html\" title=\"trait digest::core_api::BufferKindUser\">BufferKindUser</a> + <a class=\"trait\" href=\"../digest/core_api/trait.UpdateCore.html\" title=\"trait digest::core_api::UpdateCore\">UpdateCore</a>,\n <T as <a class=\"trait\" href=\"../crypto_common/trait.BlockSizeUser.html\" title=\"trait crypto_common::BlockSizeUser\">BlockSizeUser</a>>::<a class=\"associatedtype\" href=\"../crypto_common/trait.BlockSizeUser.html#associatedtype.BlockSize\" title=\"type crypto_common::BlockSizeUser::BlockSize\">BlockSize</a>: <a class=\"trait\" href=\"../typenum/type_operators/trait.IsLess.html\" title=\"trait typenum::type_operators::IsLess\">IsLess</a><<a class=\"struct\" href=\"../typenum/uint/struct.UInt.html\" title=\"struct typenum::uint::UInt\">UInt</a><<a class=\"struct\" href=\"../typenum/uint/struct.UInt.html\" title=\"struct typenum::uint::UInt\">UInt</a><<a class=\"struct\" href=\"../typenum/uint/struct.UInt.html\" title=\"struct typenum::uint::UInt\">UInt</a><<a class=\"struct\" href=\"../typenum/uint/struct.UInt.html\" title=\"struct typenum::uint::UInt\">UInt</a><<a class=\"struct\" href=\"../typenum/uint/struct.UInt.html\" title=\"struct typenum::uint::UInt\">UInt</a><<a class=\"struct\" href=\"../typenum/uint/struct.UInt.html\" title=\"struct typenum::uint::UInt\">UInt</a><<a class=\"struct\" href=\"../typenum/uint/struct.UInt.html\" title=\"struct typenum::uint::UInt\">UInt</a><<a class=\"struct\" href=\"../typenum/uint/struct.UInt.html\" title=\"struct typenum::uint::UInt\">UInt</a><<a class=\"struct\" href=\"../typenum/uint/struct.UInt.html\" title=\"struct typenum::uint::UInt\">UInt</a><<a class=\"struct\" href=\"../typenum/uint/struct.UTerm.html\" title=\"struct typenum::uint::UTerm\">UTerm</a>, <a class=\"struct\" href=\"../typenum/bit/struct.B1.html\" title=\"struct typenum::bit::B1\">B1</a>>, <a class=\"struct\" href=\"../typenum/bit/struct.B0.html\" title=\"struct typenum::bit::B0\">B0</a>>, <a class=\"struct\" href=\"../typenum/bit/struct.B0.html\" title=\"struct typenum::bit::B0\">B0</a>>, <a class=\"struct\" href=\"../typenum/bit/struct.B0.html\" title=\"struct typenum::bit::B0\">B0</a>>, <a class=\"struct\" href=\"../typenum/bit/struct.B0.html\" title=\"struct typenum::bit::B0\">B0</a>>, <a class=\"struct\" href=\"../typenum/bit/struct.B0.html\" title=\"struct typenum::bit::B0\">B0</a>>, <a class=\"struct\" href=\"../typenum/bit/struct.B0.html\" title=\"struct typenum::bit::B0\">B0</a>>, <a class=\"struct\" href=\"../typenum/bit/struct.B0.html\" title=\"struct typenum::bit::B0\">B0</a>>, <a class=\"struct\" href=\"../typenum/bit/struct.B0.html\" title=\"struct typenum::bit::B0\">B0</a>>>,\n <<T as <a class=\"trait\" href=\"../crypto_common/trait.BlockSizeUser.html\" title=\"trait crypto_common::BlockSizeUser\">BlockSizeUser</a>>::<a class=\"associatedtype\" href=\"../crypto_common/trait.BlockSizeUser.html#associatedtype.BlockSize\" title=\"type crypto_common::BlockSizeUser::BlockSize\">BlockSize</a> as <a class=\"trait\" href=\"../typenum/type_operators/trait.IsLess.html\" title=\"trait typenum::type_operators::IsLess\">IsLess</a><<a class=\"struct\" href=\"../typenum/uint/struct.UInt.html\" title=\"struct typenum::uint::UInt\">UInt</a><<a class=\"struct\" href=\"../typenum/uint/struct.UInt.html\" title=\"struct typenum::uint::UInt\">UInt</a><<a class=\"struct\" href=\"../typenum/uint/struct.UInt.html\" title=\"struct typenum::uint::UInt\">UInt</a><<a class=\"struct\" href=\"../typenum/uint/struct.UInt.html\" title=\"struct typenum::uint::UInt\">UInt</a><<a class=\"struct\" href=\"../typenum/uint/struct.UInt.html\" title=\"struct typenum::uint::UInt\">UInt</a><<a class=\"struct\" href=\"../typenum/uint/struct.UInt.html\" title=\"struct typenum::uint::UInt\">UInt</a><<a class=\"struct\" href=\"../typenum/uint/struct.UInt.html\" title=\"struct typenum::uint::UInt\">UInt</a><<a class=\"struct\" href=\"../typenum/uint/struct.UInt.html\" title=\"struct typenum::uint::UInt\">UInt</a><<a class=\"struct\" href=\"../typenum/uint/struct.UInt.html\" title=\"struct typenum::uint::UInt\">UInt</a><<a class=\"struct\" href=\"../typenum/uint/struct.UTerm.html\" title=\"struct typenum::uint::UTerm\">UTerm</a>, <a class=\"struct\" href=\"../typenum/bit/struct.B1.html\" title=\"struct typenum::bit::B1\">B1</a>>, <a class=\"struct\" href=\"../typenum/bit/struct.B0.html\" title=\"struct typenum::bit::B0\">B0</a>>, <a class=\"struct\" href=\"../typenum/bit/struct.B0.html\" title=\"struct typenum::bit::B0\">B0</a>>, <a class=\"struct\" href=\"../typenum/bit/struct.B0.html\" title=\"struct typenum::bit::B0\">B0</a>>, <a class=\"struct\" href=\"../typenum/bit/struct.B0.html\" title=\"struct typenum::bit::B0\">B0</a>>, <a class=\"struct\" href=\"../typenum/bit/struct.B0.html\" title=\"struct typenum::bit::B0\">B0</a>>, <a class=\"struct\" href=\"../typenum/bit/struct.B0.html\" title=\"struct typenum::bit::B0\">B0</a>>, <a class=\"struct\" href=\"../typenum/bit/struct.B0.html\" title=\"struct typenum::bit::B0\">B0</a>>, <a class=\"struct\" href=\"../typenum/bit/struct.B0.html\" title=\"struct typenum::bit::B0\">B0</a>>>>::<a class=\"associatedtype\" href=\"../typenum/type_operators/trait.IsLess.html#associatedtype.Output\" title=\"type typenum::type_operators::IsLess::Output\">Output</a>: <a class=\"trait\" href=\"../typenum/marker_traits/trait.NonZero.html\" title=\"trait typenum::marker_traits::NonZero\">NonZero</a>,</div></div>"}</script></section></div></main></body></html> |