1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
use crate::;
use Hasher;
use HashAlgorithm;
use ExtendedOutputFunction;
use ;
/// `Sha3_512Hasher` is a type that provides the SHA3-512 hashing algorithm in Rust.
///
/// In the context of cryptographic hashing, a "Hasher" is the object that manages the process of transforming input
/// data into a fixed-size sequence of bytes. The Hasher is in charge of maintaining the internal state of the
/// hashing process and offering methods to append more data and obtain the resultant hash.
///
/// The `Sha3_512Hasher` struct conforms to Rust's `Hasher` trait, allowing you to use it interchangeably with other hashers
/// in Rust. It can be utilized wherever a type implementing `Hasher` is needed.
///
/// ## Examples
///
/// The following examples illustrate using `Sha3_512Hasher` with both `Hash` and `Hasher`, and explain the differences
/// between the two:
///
///```rust
/// # use std::hash::{BuildHasher, Hash, Hasher};
/// # use rs_sha3_512::Sha3_512State;
/// let data = b"hello";
///
/// // Using Hash
/// let mut sha3_512hasher = Sha3_512State::default().build_hasher();
/// data.hash(&mut sha3_512hasher);
/// let result_via_hash = sha3_512hasher.finish();
///
/// // Using Hasher
/// let mut sha3_512hasher = Sha3_512State::default().build_hasher();
/// sha3_512hasher.write(data);
/// let result_via_hasher = sha3_512hasher.finish();
///
/// // Simulating the Hash inners
/// let mut sha3_512hasher = Sha3_512State::default().build_hasher();
/// sha3_512hasher.write_usize(data.len());
/// sha3_512hasher.write(data);
/// let simulated_hash_result = sha3_512hasher.finish();
///
/// assert_ne!(result_via_hash, result_via_hasher);
/// assert_eq!(result_via_hash, simulated_hash_result);
///```
;