File tree 2 files changed +8
-11
lines changed
2 files changed +8
-11
lines changed Original file line number Diff line number Diff line change 1
1
[package ]
2
2
name = " cargo-util"
3
- version = " 0.2.3 "
3
+ version = " 0.2.4 "
4
4
edition = " 2021"
5
5
license = " MIT OR Apache-2.0"
6
6
homepage = " https://github.com/rust-lang/cargo"
@@ -9,7 +9,7 @@ description = "Miscellaneous support code used by Cargo."
9
9
10
10
[dependencies ]
11
11
anyhow = " 1.0.34"
12
- crypto-hash = " 0.3.1 "
12
+ sha2 = " 0.10.6 "
13
13
filetime = " 0.2.9"
14
14
hex = " 0.4.2"
15
15
jobserver = " 0.1.26"
Original file line number Diff line number Diff line change 1
1
use super :: paths;
2
2
use anyhow:: { Context , Result } ;
3
- use crypto_hash :: { Algorithm , Hasher } ;
3
+ use sha2 :: { Digest , Sha256 as Sha2_sha256 } ;
4
4
use std:: fs:: File ;
5
- use std:: io:: { self , Read , Write } ;
5
+ use std:: io:: { self , Read } ;
6
6
use std:: path:: Path ;
7
7
8
- pub struct Sha256 ( Hasher ) ;
8
+ pub struct Sha256 ( Sha2_sha256 ) ;
9
9
10
10
impl Sha256 {
11
11
pub fn new ( ) -> Sha256 {
12
- let hasher = Hasher :: new ( Algorithm :: SHA256 ) ;
12
+ let hasher = Sha2_sha256 :: new ( ) ;
13
13
Sha256 ( hasher)
14
14
}
15
15
16
16
pub fn update ( & mut self , bytes : & [ u8 ] ) -> & mut Sha256 {
17
- let _ = self . 0 . write_all ( bytes) ;
17
+ let _ = self . 0 . update ( bytes) ;
18
18
self
19
19
}
20
20
@@ -38,10 +38,7 @@ impl Sha256 {
38
38
}
39
39
40
40
pub fn finish ( & mut self ) -> [ u8 ; 32 ] {
41
- let mut ret = [ 0u8 ; 32 ] ;
42
- let data = self . 0 . finish ( ) ;
43
- ret. copy_from_slice ( & data[ ..] ) ;
44
- ret
41
+ self . 0 . finalize_reset ( ) . into ( )
45
42
}
46
43
47
44
pub fn finish_hex ( & mut self ) -> String {
You can’t perform that action at this time.
0 commit comments