mirror of
https://github.com/uutils/coreutils
synced 2024-07-23 19:04:18 +00:00
update to sha 0.10.0 (#3110)
* update to sha 0.10.0 * correct formatting
This commit is contained in:
parent
45a1b7e4bb
commit
d9c2acc2ed
21
Cargo.lock
generated
21
Cargo.lock
generated
|
@ -312,6 +312,7 @@ dependencies = [
|
|||
"conv",
|
||||
"filetime",
|
||||
"glob",
|
||||
"hex-literal",
|
||||
"lazy_static",
|
||||
"libc",
|
||||
"nix 0.23.1",
|
||||
|
@ -903,6 +904,12 @@ version = "0.2.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d6a22814455d41612f41161581c2883c0c6a1c41852729b17d5ed88f01e153aa"
|
||||
|
||||
[[package]]
|
||||
name = "hex-literal"
|
||||
version = "0.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0"
|
||||
|
||||
[[package]]
|
||||
name = "hostname"
|
||||
version = "0.3.1"
|
||||
|
@ -1737,19 +1744,15 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "sha1"
|
||||
version = "0.6.1"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c1da05c97445caa12d05e848c4a4fcbbea29e748ac28f7e80e9b010392063770"
|
||||
checksum = "04cc229fb94bcb689ffc39bd4ded842f6ff76885efede7c6d1ffb62582878bea"
|
||||
dependencies = [
|
||||
"sha1_smol",
|
||||
"cfg-if 1.0.0",
|
||||
"cpufeatures",
|
||||
"digest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha1_smol"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012"
|
||||
|
||||
[[package]]
|
||||
name = "sha2"
|
||||
version = "0.10.1"
|
||||
|
|
|
@ -372,13 +372,14 @@ libc = "0.2"
|
|||
pretty_assertions = "1"
|
||||
rand = "0.8"
|
||||
regex = "1.0"
|
||||
sha1 = { version="0.6", features=["std"] }
|
||||
sha1 = { version="0.10", features=["std"] }
|
||||
tempfile = "3.2.0"
|
||||
time = "0.1"
|
||||
unindent = "0.1"
|
||||
uucore = { version=">=0.0.11", package="uucore", path="src/uucore", features=["entries", "process"] }
|
||||
walkdir = "2.2"
|
||||
atty = "0.2"
|
||||
hex-literal = "0.3.1"
|
||||
|
||||
[target.'cfg(target_os = "linux")'.dev-dependencies]
|
||||
rlimit = "0.4.0"
|
||||
|
|
|
@ -23,7 +23,7 @@ memchr = "2"
|
|||
md5 = "0.3.5"
|
||||
regex = "1.0.1"
|
||||
regex-syntax = "0.6.7"
|
||||
sha1 = "0.6.0"
|
||||
sha1 = "0.10.0"
|
||||
sha2 = "0.10.1"
|
||||
sha3 = "0.10.0"
|
||||
blake2b_simd = "0.5.11"
|
||||
|
|
|
@ -106,19 +106,19 @@ impl Digest for blake3::Hasher {
|
|||
|
||||
impl Digest for sha1::Sha1 {
|
||||
fn new() -> Self {
|
||||
Self::new()
|
||||
Self::default()
|
||||
}
|
||||
|
||||
fn input(&mut self, input: &[u8]) {
|
||||
self.update(input);
|
||||
digest::Digest::update(self, input);
|
||||
}
|
||||
|
||||
fn result(&mut self, out: &mut [u8]) {
|
||||
out.copy_from_slice(&self.digest().bytes());
|
||||
digest::Digest::finalize_into_reset(self, out.into());
|
||||
}
|
||||
|
||||
fn reset(&mut self) {
|
||||
self.reset();
|
||||
*self = Self::new();
|
||||
}
|
||||
|
||||
fn output_bits(&self) -> usize {
|
||||
|
|
|
@ -29,6 +29,8 @@ const NUM_TESTS: usize = 100;
|
|||
|
||||
#[test]
|
||||
fn test_parallel() {
|
||||
use hex_literal::hex;
|
||||
use sha1::{Digest, Sha1};
|
||||
// factor should only flush the buffer at line breaks
|
||||
let n_integers = 100_000;
|
||||
let mut input_string = String::new();
|
||||
|
@ -60,13 +62,20 @@ fn test_parallel() {
|
|||
.ccmd("sort")
|
||||
.arg(tmp_dir.plus("output"))
|
||||
.succeeds();
|
||||
let hash_check = sha1::Sha1::from(result.stdout()).hexdigest();
|
||||
assert_eq!(hash_check, "cc743607c0ff300ff575d92f4ff0c87d5660c393");
|
||||
let mut hasher = Sha1::new();
|
||||
hasher.update(result.stdout());
|
||||
let hash_check = hasher.finalize();
|
||||
assert_eq!(
|
||||
hash_check[..],
|
||||
hex!("cc743607c0ff300ff575d92f4ff0c87d5660c393")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_first_100000_integers() {
|
||||
extern crate sha1;
|
||||
use hex_literal::hex;
|
||||
use sha1::{Digest, Sha1};
|
||||
|
||||
let n_integers = 100_000;
|
||||
let mut input_string = String::new();
|
||||
|
@ -78,8 +87,13 @@ fn test_first_100000_integers() {
|
|||
let result = new_ucmd!().pipe_in(input_string.as_bytes()).succeeds();
|
||||
|
||||
// `seq 0 100000 | factor | sha1sum` => "4ed2d8403934fa1c76fe4b84c5d4b8850299c359"
|
||||
let hash_check = sha1::Sha1::from(result.stdout()).hexdigest();
|
||||
assert_eq!(hash_check, "4ed2d8403934fa1c76fe4b84c5d4b8850299c359");
|
||||
let mut hasher = Sha1::new();
|
||||
hasher.update(result.stdout());
|
||||
let hash_check = hasher.finalize();
|
||||
assert_eq!(
|
||||
hash_check[..],
|
||||
hex!("4ed2d8403934fa1c76fe4b84c5d4b8850299c359")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Reference in a new issue