23 lines
842 B
Rust
23 lines
842 B
Rust
use std::sync::LazyLock;
|
|
use std::str::FromStr;
|
|
use rug::Integer;
|
|
use rug::integer::Order;
|
|
use sha2::{Sha256, Digest};
|
|
|
|
static M: LazyLock<Integer> = LazyLock::new(|| Integer::from_str("14004392365098131090160062970945115111185775413941111064876648140973294115502980816410773368597517292734034227298996122159833675150497554142801209096513652073059992938078366061434391648276904643753267405058183481162693381822800709938988762923").unwrap());
|
|
static E: LazyLock<Integer> = LazyLock::new(|| Integer::from(65537));
|
|
|
|
pub fn solve(name: &str) -> (u64, Integer) {
|
|
let mut x = sha256(name);
|
|
x += 4;
|
|
for _ in 0..10_000 {
|
|
for _ in 0..100 {
|
|
x.pow_mod_mut(&E, &M).unwrap();
|
|
}
|
|
}
|
|
(20_000, x)
|
|
}
|
|
|
|
pub fn sha256(name: &str) -> Integer {
|
|
Integer::from_digits(Sha256::digest(name).as_slice(), Order::MsfBe)
|
|
} |