Debian Codegraph @

debian/rust-vendor/sha1/README.md

raw
1 # RustCrypto: SHA-1
2
3 [![crate][crate-image]][crate-link]
4 [![Docs][docs-image]][docs-link]
5 ![Apache2/MIT licensed][license-image]
6 ![Rust Version][rustc-image]
7 [![Project Chat][chat-image]][chat-link]
8 [![Build Status][build-image]][build-link]
9
10 Pure Rust implementation of the [SHA-1] cryptographic hash algorithm.
11
12 ## Warning: Cryptographically Broken!
13
14 The SHA-1 hash function should be considered cryptographically broken and
15 unsuitable for further use in any security critical capacity, as it is
16 [practically vulnerable to chosen-prefix collisions][1].
17
18 We provide this crate for legacy interoperability purposes only.
19
20 If possible use the [sha1-checked] crate, while slower it provides the ability to
21 detect potential collisions, as well as generate alternative safe hashes.
22
23 ## Examples
24
25 ### One-shot API
26
27 ```rust
28 use hex_literal::hex;
29 use sha1::{Sha1, Digest};
30
31 let result = Sha1::digest(b"hello world");
32 assert_eq!(result, hex!("2aae6c35c94fcfb415dbe95f408b9ce91ee846ed"));
33 ```
34
35 ### Incremental API
36
37 ```rust
38 use hex_literal::hex;
39 use sha1::{Sha1, Digest};
40
41 let mut hasher = Sha1::new();
42 hasher.update(b"hello world");
43 let hash = hasher.finalize();
44
45 assert_eq!(hash, hex!("2aae6c35c94fcfb415dbe95f408b9ce91ee846ed"));
46 ```
47
48 See the [`digest`] crate docs for additional examples.
49
50 ## License
51
52 The crate is licensed under either of:
53
54 * [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
55 * [MIT license](http://opensource.org/licenses/MIT)
56
57 at your option.
58
59 ### Contribution
60
61 Unless you explicitly state otherwise, any contribution intentionally submitted
62 for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
63 dual licensed as above, without any additional terms or conditions.
64
65 [//]: # (badges)
66
67 [crate-image]: https://img.shields.io/crates/v/sha1.svg
68 [crate-link]: https://crates.io/crates/sha1
69 [docs-image]: https://docs.rs/sha1/badge.svg
70 [docs-link]: https://docs.rs/sha1/
71 [license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg
72 [rustc-image]: https://img.shields.io/badge/rustc-1.85+-blue.svg
73 [chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg
74 [chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260041-hashes
75 [build-image]: https://github.com/RustCrypto/hashes/actions/workflows/sha1.yml/badge.svg?branch=master
76 [build-link]: https://github.com/RustCrypto/hashes/actions/workflows/sha1.yml?query=branch:master
77
78 [//]: # (general links)
79
80 [SHA-1]: https://en.wikipedia.org/wiki/SHA-1
81 [1]: https://sha-mbles.github.io/
82 [`digest`]: https://docs.rs/digest
83 [sha1-checked]: https://crates.io/crates/sha1-checked