rust-ml/book

sha256 wrong apis in 0.9.3

Closed this issue · 1 comments

/// 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
}

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