2023-10-14 23:40:14 +05:30
|
|
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
2021-03-06 17:07:28 +05:30
|
|
|
/* The easiest way to use this crate is with the default configuration.
|
|
|
|
* See `Default` implementation for the default configuration.
|
|
|
|
*/
|
|
|
|
|
|
|
|
use pow_sha256::{ConfigBuilder, PoW};
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let config = ConfigBuilder::default()
|
|
|
|
.salt("myrandomsaltisnotlongenoug".into())
|
|
|
|
.build()
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
let phrase = "ironmansucks";
|
|
|
|
|
2021-03-08 18:27:18 +05:30
|
|
|
const DIFFICULTY: u32 = 1000;
|
2021-03-06 17:07:28 +05:30
|
|
|
|
|
|
|
let work = config.prove_work(&phrase, DIFFICULTY).unwrap();
|
|
|
|
assert!(config.is_valid_proof(&work, &phrase));
|
|
|
|
assert!(config.is_sufficient_difficulty(&work, DIFFICULTY));
|
|
|
|
}
|