actually put in algs
This commit is contained in:
parent
621eff415c
commit
6f0c2c0f44
2 changed files with 87 additions and 2 deletions
|
@ -17,6 +17,7 @@ use md2::Md2;
|
|||
use md4::Md4;
|
||||
use md5::Md5;
|
||||
use ripemd::{Ripemd128, Ripemd160, Ripemd256, Ripemd320};
|
||||
use sha1::Sha1;
|
||||
use sha2::{Digest, Sha224, Sha256, Sha384, Sha512};
|
||||
// use sha3::{Sha3_224, Sha3_256, Sha3_384, Sha3_512, Shake128, Shake256};
|
||||
use sha3::{Sha3_224, Sha3_256, Sha3_384, Sha3_512};
|
||||
|
@ -382,6 +383,13 @@ pub fn hash_md5(mut file: File) -> String {
|
|||
return format!("{:x}", hasher.finalize());
|
||||
}
|
||||
|
||||
pub fn hash_sha1(mut file: File) -> String {
|
||||
let mut hasher = Sha1::new();
|
||||
_ = io::copy(&mut file, &mut hasher);
|
||||
|
||||
return format!("{:x}", hasher.finalize());
|
||||
}
|
||||
|
||||
pub fn hash_sha256(mut file: File) -> String {
|
||||
let mut hasher = Sha256::new();
|
||||
_ = io::copy(&mut file, &mut hasher);
|
||||
|
|
81
src/main.rs
81
src/main.rs
|
@ -9,8 +9,54 @@ use std::thread::{self, available_parallelism, JoinHandle};
|
|||
mod common;
|
||||
mod hashers;
|
||||
|
||||
const ALGORITHMS: [&'static str; 3] = ["sha256", "sha384", "sha512"];
|
||||
const UNSECURE_ALGORITHMS: [&'static str; 1] = ["md5"];
|
||||
const ALGORITHMS: [&'static str; 37] = [
|
||||
"ascon",
|
||||
"belt",
|
||||
"blake2b512",
|
||||
"blake2s256",
|
||||
"fsb160",
|
||||
"fsb224",
|
||||
"fsb256",
|
||||
"fsb384",
|
||||
"fsb512",
|
||||
"groestl224",
|
||||
"groestl256",
|
||||
"groestl384",
|
||||
"groestl512",
|
||||
"jh224",
|
||||
"jh256",
|
||||
"jh384",
|
||||
"jh512",
|
||||
"ripemd128",
|
||||
"ripemd160",
|
||||
"ripemd256",
|
||||
"ripemd320",
|
||||
"sha224",
|
||||
"sha256",
|
||||
"sha384",
|
||||
"sha512",
|
||||
"sha3_224",
|
||||
"sha3_256",
|
||||
"sha3_384",
|
||||
"sha3_512",
|
||||
"shabal192",
|
||||
"shabal224",
|
||||
"shabal256",
|
||||
"shabal384",
|
||||
"shabal512",
|
||||
"sm3",
|
||||
"tiger",
|
||||
"whirlpool",
|
||||
];
|
||||
const UNSECURE_ALGORITHMS: [&'static str; 7] = [
|
||||
"gost94",
|
||||
"md2",
|
||||
"md4",
|
||||
"md5",
|
||||
"sha1",
|
||||
"streebog256",
|
||||
"streebog512",
|
||||
];
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(name = "psha")]
|
||||
|
@ -137,10 +183,41 @@ fn hash(info: ThreadInfo) -> Result<(), String> {
|
|||
"fsb256" => hashers::hash_fsb256(file),
|
||||
"fsb384" => hashers::hash_fsb384(file),
|
||||
"fsb512" => hashers::hash_fsb512(file),
|
||||
"gost94" => hashers::hash_gost94(file),
|
||||
"groestl224" => hashers::hash_groestl224(file),
|
||||
"groestl256" => hashers::hash_groestl256(file),
|
||||
"groestl384" => hashers::hash_groestl384(file),
|
||||
"groestl512" => hashers::hash_groestl512(file),
|
||||
"jh224" => hashers::hash_jh224(file),
|
||||
"jh256" => hashers::hash_jh256(file),
|
||||
"jh384" => hashers::hash_jh384(file),
|
||||
"jh512" => hashers::hash_jh512(file),
|
||||
"md2" => hashers::hash_md2(file),
|
||||
"md4" => hashers::hash_md4(file),
|
||||
"md5" => hashers::hash_md5(file),
|
||||
"ripemd128" => hashers::hash_ripemd128(file),
|
||||
"ripemd160" => hashers::hash_ripemd160(file),
|
||||
"ripemd256" => hashers::hash_ripemd256(file),
|
||||
"ripemd320" => hashers::hash_ripemd320(file),
|
||||
"sha1" => hashers::hash_sha1(file),
|
||||
"sha224" => hashers::hash_sha224(file),
|
||||
"sha256" => hashers::hash_sha256(file),
|
||||
"sha384" => hashers::hash_sha384(file),
|
||||
"sha512" => hashers::hash_sha512(file),
|
||||
"sha3_224" => hashers::hash_sha3_224(file),
|
||||
"sha3_256" => hashers::hash_sha3_256(file),
|
||||
"sha3_384" => hashers::hash_sha3_384(file),
|
||||
"sha3_512" => hashers::hash_sha3_512(file),
|
||||
"shabal192" => hashers::hash_shabal192(file),
|
||||
"shabal224" => hashers::hash_shabal224(file),
|
||||
"shabal256" => hashers::hash_shabal256(file),
|
||||
"shabal384" => hashers::hash_shabal384(file),
|
||||
"shabal512" => hashers::hash_shabal512(file),
|
||||
"sm3" => hashers::hash_sm3(file),
|
||||
"streebog256" => hashers::hash_streebog256(file),
|
||||
"streebog512" => hashers::hash_streebog512(file),
|
||||
"tiger" => hashers::hash_tiger(file),
|
||||
"whirlpool" => hashers::hash_whirlpool(file),
|
||||
_ => panic!("Somehow did not pass a supported algorithm"),
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue