add RIPEMD160

This commit is contained in:
2019-11-24 12:17:34 +08:00
parent e8f3c47416
commit 339c4e2ab7
3 changed files with 5 additions and 3 deletions

2
Cargo.lock generated
View File

@@ -142,7 +142,7 @@ dependencies = [
[[package]]
name = "digest"
version = "0.1.1"
version = "0.1.2"
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)",

View File

@@ -1,6 +1,6 @@
[package]
name = "digest"
version = "0.1.1"
version = "0.1.2"
authors = ["Hatter Jiang <jht5945@gmail.com>"]
edition = "2018"

View File

@@ -12,6 +12,7 @@ use std::{
};
use crypto::{
digest::Digest,
ripemd160::Ripemd160,
md5::Md5,
sha1::Sha1,
sha2::{
@@ -124,12 +125,13 @@ Written by Hatter Jiang
Supported algorithms:
MD5, SHA1, SHA224, SHA256, SHA512, SHA512-224, SHA512-256,
SHA3-224, SHA3-256, SHA3-384, SHA3-512, SHAKE-128, SHAKE-256,
KECCAK-224, KECCAK-256, KECCAK-384, KECCAK-512, SM3
KECCAK-224, KECCAK-256, KECCAK-384, KECCAK-512, SM3, RIPEMD160
"#, VERSION, &GIT_HASH[0..7]);
}
fn get_digest_by_algorithm(algo: &str) -> Option<Box<dyn Digest>> {
match algo {
"RIPEMD160" => Some(Box::new(Ripemd160::new())),
"MD5" => Some(Box::new(Md5::new())),
"SHA1" | "SHA-1" => Some(Box::new(Sha1::new())),
"SHA224" | "SHA-224" => Some(Box::new(Sha224::new())),