Created
December 7, 2019 02:00
-
-
Save lnds/44b4d7b2cb439272b3829138ba1beb47 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Sha512 in Rust | |
#[macro_use] | |
extern crate itertools; | |
use sha2::{Digest, Sha512}; | |
fn main() { | |
let target = Sha512::new().chain(b"help").result(); | |
let alpha = "abcdefghijklmnopqrstuvwxyz"; | |
let col = iproduct!(alpha.chars(), alpha.chars(), alpha.chars(), alpha.chars()) | |
.map(|(a, b, c, d)| format!("{}{}{}{}", a, b, c, d)) | |
.filter(|candidate| Sha512::new().chain(&candidate).result() == target) | |
.collect::<Vec<String>>(); | |
println!("{:?}", col); | |
} | |
// time cargo run --release | |
// real 0m0.304s | |
// user 0m0.284s | |
// sys 0m0.015s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment