rust sha256 solver cargo run file.txt 2 ⎗ ✓ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40use sha256::{digest}; use std::fs::File; use std::io::prelude::*; use std::env; fn main() -> std::io::Result<()> { let args: Vec<String> = env::args().collect(); let filename = &args[1]; let max: u32 = args[2].parse().unwrap(); let mut file = File::open(filename)?; let mut contents = String::new(); file.read_to_string(&mut contents)?; for i in 0..100000 { let s: String = i.to_string(); let mut contents_n = contents.clone(); contents_n += &s; let hash = digest(contents_n); let mut chars = hash.chars(); for i in 0..max { let c = chars.next().unwrap(); if c.eq(&'0') { //println!("{} {} {}", c, i, max); if i + 1 == max { println!("{}", hash); return Ok(()) } } else { break } } } Ok(()) }