rust-ml / book

The Rust Machine Learning Book
https://rust-ml.github.io/book/
Apache License 2.0
199 stars 21 forks source link

sha256 wrong apis in 0.9.3 #3

Closed bruceloco closed 3 years ago

bruceloco commented 3 years ago

/// Convert input string to 24 character hash pub fn hash(input: &str) -> String { let mut sh = Sha256::new(); sh.input(input.as_bytes()); let mut out = format!("{:x}", sh.result()); out.truncate(24); out }

Does not build, input and result are not registered apis

changed to /// Convert input string to 24 character hash pub fn hash(input: &str) -> String { let mut sh = Sha256::new(); sh.update(input.as_bytes()); let mut out = format!("{:x}", sh.finalize()); out.truncate(24); out }

bytesnake commented 3 years ago

I pushed a small fix in ef62f6a, the state of the book is currently a bit unclear