Skip to content

Commit

Permalink
GH #9 - Replace MD5 checksum on blob with a safe hasher
Browse files Browse the repository at this point in the history
Add MD5 to the simple secure hash benchmark.
  • Loading branch information
tatsuya6502 committed May 23, 2017
1 parent 525d560 commit fc65336
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions examples/hashes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ authors = ["Tatsuya Kawano <[email protected]>"]
blake2 = "0.5.2"
data-encoding = "2.0.0-rc.1"
# generic-array = "0.7.2"
md-5 = { version = "0.4.3", features = ["asm"] }
# md-5 = "0.4.3"
rand = "0.3.15"
# sha2 = { version = "0.5.2", features = ["asm"] }
sha2 = "0.5.2"
Expand Down
11 changes: 8 additions & 3 deletions examples/hashes/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@
// ----------------------------------------------------------------------

extern crate blake2;
extern crate data_encoding;
extern crate rand;
extern crate md_5 as md5;
extern crate sha2;
extern crate sha3;

extern crate rand;
extern crate data_encoding;

use std::time::Instant;

// use digest::Digest;
use blake2::{Blake2s, Digest};
use md5::Md5;
use sha2::Sha256;
use sha3::Sha3_256;

Expand All @@ -35,11 +38,13 @@ fn main() {

println!("Input data length: {:.2} GB", input_len as f64 / 1024.0 / 1024.0 / 1024.0);

let elapse_md5 = hash::<Md5>(input_len, "MD5 ");
let elapse_sha256 = hash::<Sha256>(input_len, "SHA-256 ");
let elapse_sha3_256 = hash::<Sha3_256>(input_len, "SHA-3-256");
let elapse_blake2 = hash::<Blake2s>(input_len, "Blake2s ");

println!("SHA-256: 1.00x, SHA-3-256: {:.2}x, Blake2s: {:.2}x",
println!("MD5: {:.2}x, SHA-256: 1.00x, SHA-3-256: {:.2}x, Blake2s: {:.2}x",
elapse_sha256 / elapse_md5,
elapse_sha256 / elapse_sha3_256,
elapse_sha256 / elapse_blake2);
}
Expand Down

0 comments on commit fc65336

Please sign in to comment.