amulets/src/main.rs
2024-11-14 00:31:51 -05:00

130 lines
3.2 KiB
Rust

use std::process::exit;
use itertools::Itertools;
use rayon::prelude::*;
use sha2::{Digest, Sha256};
// we could be smart with prefixes
#[allow(clippy::too_many_lines)]
fn main() {
let choices = [
vec![
"",
"they say ",
"they say that ",
"it's true! ",
"it's true: ",
"did you know ",
"did you know that ",
],
vec!["the "],
vec![
"sha",
"Sha",
"SHA",
"sha-",
"SHA-",
"Sha-",
"sha ",
"Sha ",
"SHA ",
"Secure Hash Algorithm ",
"secure hash algorithm ",
],
vec![
"256",
"2 5 6",
"two five six",
"two-fifty-six",
"two hundred and fifty six",
],
vec![" "],
vec!["hash", "digest"],
vec![" of "],
vec!["this sentence", "this message", "this piece of digitext"],
vec![" has "],
vec![
"ten",
"10",
"10 (ten)",
"ten (10)",
"10!",
"10(!)",
"ten!",
"ten(!)",
"10!!",
"10(!!)",
"ten!!",
"ten(!!)",
"10!!!",
"10(!!!)",
"ten!!!",
"ten(!!!)",
"10!!!!!!!!!!",
"10(!!!!!!!!!!)",
"ten!!!!!!!!!!",
"ten(!!!!!!!!!!)",
],
vec![" "],
vec![
"0s",
"zeroes",
"0s!",
"0s(!)",
"zeroes!",
"zeroes(!)",
"0s!!",
"0s(!!)",
"zeroes!!",
"zeroes(!!)",
"0s!!!",
"0s(!!!)",
"zeroes!!!",
"zeroes(!!!)",
"0s!!!!!!!!!!",
"0s(!!!!!!!!!!)",
"zeroes!!!!!!!!!!",
"zeroes(!!!!!!!!!!)",
],
vec![" "],
vec![
"in a row",
"in one group",
"all together",
"all together :)",
],
vec!["! ", ". ", " "],
vec![
"isn't that",
"i think that's",
"that's",
"that is",
"i think that is",
"that fact is",
],
vec![" "],
vec!["somewhat ", "pretty ", "quite ", "very ", "decently ", ""],
vec!["fun", "nice", "sweet", "pleasant", "cool", "interesting"],
vec![" "],
vec![
":)", ":D", ":))", ":)))", "XD", ":B", ">:)", ">:D", ">XD", ">:B", "B)", "BD", ">B)",
">BD", "(:", "((:", "(((:", "(:<",
],
];
choices
.into_iter()
.multi_cartesian_product()
.par_bridge()
.for_each(|selection| {
let mut hasher = Sha256::new();
for choice in &selection {
hasher.update(choice);
}
let digest = hasher.finalize();
if format!("{digest:x}").contains("0000000000") {
println!("{}\n{digest:x}", selection.join(""));
exit(0);
}
});
}