From 9737ecce41bef32f8c6ce972f912abe67260799a Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Sat, 23 Nov 2019 19:28:35 +0800 Subject: [PATCH] change outputs, version to 0.1.1 --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/main.rs | 38 +++++++++++++++++++------------------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d2abf99..afcc852 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -142,7 +142,7 @@ dependencies = [ [[package]] name = "digest" -version = "0.1.0" +version = "0.1.1" dependencies = [ "argparse 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index cb84c68..03c41f9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "digest" -version = "0.1.0" +version = "0.1.1" authors = ["Hatter Jiang "] edition = "2018" diff --git a/src/main.rs b/src/main.rs index 82f2ae4..af95b0c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -93,25 +93,25 @@ fn main() -> XResult<()> { let the_algo = options.algorithm.to_uppercase(); match the_algo.as_str() { - "MD5" => println!("{}: {}", the_algo, calc_file_digest(&mut Md5::new(), the_fn)?), - "SHA1" | "SHA-1" => println!("{}: {}", the_algo, calc_file_digest(&mut Sha1::new(), the_fn)?), - "SHA224" | "SHA-224" => println!("{}: {}", the_algo, calc_file_digest(&mut Sha224::new(), the_fn)?), - "SHA256" | "SHA-256" => println!("{}: {}", the_algo, calc_file_digest(&mut Sha256::new(), the_fn)?), - "SHA384" | "SHA-384" => println!("{}: {}", the_algo, calc_file_digest(&mut Sha384::new(), the_fn)?), - "SHA512" | "SHA-512" => println!("{}: {}", the_algo, calc_file_digest(&mut Sha512::new(), the_fn)?), - "SHA512-224" => println!("{}: {}", the_algo, calc_file_digest(&mut Sha512Trunc224::new(), the_fn)?), - "SHA512-256" => println!("{}: {}", the_algo, calc_file_digest(&mut Sha512Trunc256::new(), the_fn)?), - "SHA3-224" => println!("{}: {}", the_algo, calc_file_digest(&mut Sha3::sha3_224(), the_fn)?), - "SHA3-256" => println!("{}: {}", the_algo, calc_file_digest(&mut Sha3::sha3_256(), the_fn)?), - "SHA3-384" => println!("{}: {}", the_algo, calc_file_digest(&mut Sha3::sha3_384(), the_fn)?), - "SHA3-512" => println!("{}: {}", the_algo, calc_file_digest(&mut Sha3::sha3_512(), the_fn)?), - "SHAKE-128" => println!("{}: {}", the_algo, calc_file_digest(&mut Sha3::shake_128(), the_fn)?), - "SHAKE-256" => println!("{}: {}", the_algo, calc_file_digest(&mut Sha3::shake_256(), the_fn)?), - "KECCAK-224" => println!("{}: {}", the_algo, calc_file_digest(&mut Sha3::keccak224(), the_fn)?), - "KECCAK-256" => println!("{}: {}", the_algo, calc_file_digest(&mut Sha3::keccak256(), the_fn)?), - "KECCAK-384" => println!("{}: {}", the_algo, calc_file_digest(&mut Sha3::keccak384(), the_fn)?), - "KECCAK-512" => println!("{}: {}", the_algo, calc_file_digest(&mut Sha3::keccak512(), the_fn)?), - "SM3" => println!("{}: {}", the_algo, hex::encode(Sm3Hash::new(&read_file_full(the_fn)?).get_hash())), + "MD5" => println!("{} - {} ({})", calc_file_digest(&mut Md5::new(), the_fn)?, the_fn, the_algo), + "SHA1" | "SHA-1" => println!("{} - {} ({})", calc_file_digest(&mut Sha1::new(), the_fn)?, the_fn, the_algo), + "SHA224" | "SHA-224" => println!("{} - {} ({})", calc_file_digest(&mut Sha224::new(), the_fn)?, the_fn, the_algo), + "SHA256" | "SHA-256" => println!("{} - {} ({})", calc_file_digest(&mut Sha256::new(), the_fn)?, the_fn, the_algo), + "SHA384" | "SHA-384" => println!("{} - {} ({})", calc_file_digest(&mut Sha384::new(), the_fn)?, the_fn, the_algo), + "SHA512" | "SHA-512" => println!("{} - {} ({})", calc_file_digest(&mut Sha512::new(), the_fn)?, the_fn, the_algo), + "SHA512-224" => println!("{} - {} ({})", calc_file_digest(&mut Sha512Trunc224::new(), the_fn)?, the_fn, the_algo), + "SHA512-256" => println!("{} - {} ({})", calc_file_digest(&mut Sha512Trunc256::new(), the_fn)?, the_fn, the_algo), + "SHA3-224" => println!("{} - {} ({})", calc_file_digest(&mut Sha3::sha3_224(), the_fn)?, the_fn, the_algo), + "SHA3-256" => println!("{} - {} ({})", calc_file_digest(&mut Sha3::sha3_256(), the_fn)?, the_fn, the_algo), + "SHA3-384" => println!("{} - {} ({})", calc_file_digest(&mut Sha3::sha3_384(), the_fn)?, the_fn, the_algo), + "SHA3-512" => println!("{} - {} ({})", calc_file_digest(&mut Sha3::sha3_512(), the_fn)?, the_fn, the_algo), + "SHAKE-128" => println!("{} - {} ({})", calc_file_digest(&mut Sha3::shake_128(), the_fn)?, the_fn, the_algo), + "SHAKE-256" => println!("{} - {} ({})", calc_file_digest(&mut Sha3::shake_256(), the_fn)?, the_fn, the_algo), + "KECCAK-224" => println!("{} - {} ({})", calc_file_digest(&mut Sha3::keccak224(), the_fn)?, the_fn, the_algo), + "KECCAK-256" => println!("{} - {} ({})", calc_file_digest(&mut Sha3::keccak256(), the_fn)?, the_fn, the_algo), + "KECCAK-384" => println!("{} - {} ({})", calc_file_digest(&mut Sha3::keccak384(), the_fn)?, the_fn, the_algo), + "KECCAK-512" => println!("{} - {} ({})", calc_file_digest(&mut Sha3::keccak512(), the_fn)?, the_fn, the_algo), + "SM3" => println!("{} - {} ({})", hex::encode(Sm3Hash::new(&read_file_full(the_fn)?).get_hash()), the_fn, the_algo), _ => print_message(MessageType::ERROR, &format!("Unknown algorithm: {}", options.algorithm)), };