Skip to content

Commit

Permalink
cksum: use the qualified import to make its provenance clear
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvestre committed May 10, 2024
1 parent 42fb7bf commit 2f0cc9d
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/uu/cksum/src/cksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

// spell-checker:ignore (ToDO) fname, algo
use clap::{crate_version, value_parser, Arg, ArgAction, Command};
use hex::decode;
use hex::encode;
use std::error::Error;
use std::ffi::OsStr;
use std::fmt::Display;
Expand Down Expand Up @@ -205,7 +203,7 @@ where
ALGORITHM_OPTIONS_SYSV | ALGORITHM_OPTIONS_BSD => {
sum_hex.parse::<u16>().unwrap().to_be_bytes().to_vec()
}
_ => decode(sum_hex).unwrap(),
_ => hex::decode(sum_hex).unwrap(),
};
// Cannot handle multiple files anyway, output immediately.
stdout().write_all(&bytes)?;
Expand All @@ -214,7 +212,7 @@ where
OutputFormat::Hexadecimal => sum_hex,
OutputFormat::Base64 => match options.algo_name {
ALGORITHM_OPTIONS_CRC | ALGORITHM_OPTIONS_SYSV | ALGORITHM_OPTIONS_BSD => sum_hex,
_ => encoding::encode(encoding::Format::Base64, &decode(sum_hex).unwrap()).unwrap(),
_ => encoding::encode(encoding::Format::Base64, &hex::decode(sum_hex).unwrap()).unwrap(),
},
};
// The BSD checksum output is 5 digit integer
Expand Down Expand Up @@ -299,7 +297,7 @@ fn digest_read<T: Read>(
// Assume it's SHAKE. result_str() doesn't work with shake (as of 8/30/2016)
let mut bytes = vec![0; (output_bits + 7) / 8];
digest.hash_finalize(&mut bytes);
Ok((encode(bytes), output_size))
Ok((hex::encode(bytes), output_size))
}
}

Expand Down

0 comments on commit 2f0cc9d

Please sign in to comment.