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