pow_sha256/examples/simple.rs
Aravinth Manivannan 9fe4d52f47
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline was successful
chore: rename pow_sha256 crate (this) to mcaptcha_pow_sha256
closes: #2
2023-10-14 23:49:44 +05:30

25 lines
737 B
Rust

// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
//
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
/* The easiest way to use this crate is with the default configuration.
* See `Default` implementation for the default configuration.
*/
use mcaptcha_pow_sha256::{ConfigBuilder, PoW};
fn main() {
let config = ConfigBuilder::default()
.salt("myrandomsaltisnotlongenoug".into())
.build()
.unwrap();
let phrase = "ironmansucks";
const DIFFICULTY: u32 = 1000;
let work = config.prove_work(&phrase, DIFFICULTY).unwrap();
assert!(config.is_valid_proof(&work, &phrase));
assert!(config.is_sufficient_difficulty(&work, DIFFICULTY));
}