We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 779d55d commit 902f921Copy full SHA for 902f921
src/ch11/pow/src/main.rs
@@ -1,9 +1,8 @@
1
2
use itertools::Itertools;
3
-use crypto::{
4
- digest::Digest,
5
- sha2::Sha256,
6
-};
+use sha256::digest;
+
7
use std::{
8
thread,
9
sync::{mpsc, Arc},
@@ -16,9 +15,7 @@ static DIFFICULTY: &'static str = "00000";
16
15
struct Solution(usize, String);
17
18
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();
+ let hash = digest((number * BASE).to_string());
22
if hash.starts_with(DIFFICULTY) {
23
Some(Solution(number, hash))
24
} else { None }
0 commit comments