Skip to content

Commit 902f921

Browse files
authored
Update main.rs
1 parent 779d55d commit 902f921

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/ch11/pow/src/main.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11

22
use itertools::Itertools;
3-
use crypto::{
4-
digest::Digest,
5-
sha2::Sha256,
6-
};
3+
use sha256::digest;
4+
5+
76
use std::{
87
thread,
98
sync::{mpsc, Arc},
@@ -16,9 +15,7 @@ static DIFFICULTY: &'static str = "00000";
1615
struct Solution(usize, String);
1716

1817
fn verify(number: usize) -> Option<Solution> {
19-
let mut hasher = Sha256::new();
20-
hasher.input_str(&(number * BASE).to_string());
21-
let hash: String = hasher.result_str();
18+
let hash = digest((number * BASE).to_string());
2219
if hash.starts_with(DIFFICULTY) {
2320
Some(Solution(number, hash))
2421
} else { None }

0 commit comments

Comments
 (0)