File tree Expand file tree Collapse file tree 2 files changed +2
-37
lines changed Expand file tree Collapse file tree 2 files changed +2
-37
lines changed Original file line number Diff line number Diff line change @@ -21,34 +21,6 @@ use crate as strong_hash;
21
21
22
22
mod impls;
23
23
24
- /// `StrongHasher` is a trait for hashing functions that return more than 64
25
- /// bits of output. The key difference between `std::hash::Hasher` and
26
- /// `StrongHasher` is that `StrongHasher` produces a vec of bytes as the hash.
27
- ///
28
- /// For example, a `DefaultHasher` implementation of `StrongHasher` is as follows.
29
- ///
30
- /// ```ignore
31
- /// struct DefaultHasher2 {
32
- /// hasher: DefaultHasher,
33
- /// }
34
- ///
35
- /// impl StrongHasher for DefaultHasher2 {
36
- /// fn finish(self) -> Vec<u8> {
37
- /// self.hasher.finish().to_le_bytes().to_vec()
38
- /// }
39
- /// }
40
- /// ```
41
- pub trait StrongHasher : Hasher {
42
- /// Finishes the hash and returns the hash in bytes as a `Vec<u8>`.
43
- fn finish ( & self ) -> Vec < u8 > ;
44
- }
45
-
46
- impl < H : StrongHasher + ?Sized > StrongHasher for & mut H {
47
- fn finish ( & self ) -> Vec < u8 > {
48
- StrongHasher :: finish ( * self )
49
- }
50
- }
51
-
52
24
/// `StrongHash`` is a trait that is notionally similar to `std::hash::Hash`,
53
25
/// but carries the implicit expectation that the hash that will be produced
54
26
/// should be as perturbed as possible.
Original file line number Diff line number Diff line change 12
12
use std:: hash:: Hasher ;
13
13
14
14
use strong_hash:: StrongHash ;
15
- use strong_hash:: StrongHasher ;
16
15
17
16
#[ test]
18
17
fn test_strong_hash_derive ( ) {
@@ -60,16 +59,10 @@ fn test_strong_hash_derive() {
60
59
}
61
60
}
62
61
63
- impl StrongHasher for Blake3StrongHasher {
64
- fn finish ( & self ) -> Vec < u8 > {
65
- self . digest ( ) . as_bytes ( ) . into ( )
66
- }
67
- }
68
-
69
- fn hash ( hashable : & impl StrongHash ) -> Vec < u8 > {
62
+ fn hash ( hashable : & impl StrongHash ) -> u64 {
70
63
let mut hasher = Blake3StrongHasher :: new ( ) ;
71
64
hashable. strong_hash ( & mut hasher) ;
72
- StrongHasher :: finish ( & hasher)
65
+ Hasher :: finish ( & hasher)
73
66
}
74
67
75
68
// Now test that hashes are not equal
You can’t perform that action at this time.
0 commit comments