Currently, this results in a value of GenericArray<u8, _>:
let input = String::from("hello");
let mut hasher = Sha512::new();
hasher.update(input);
let hash_result = hasher.finalize();
However, what I need is not a byte array but a String as output.
I tried converting it with std::str::from_utf8(&hash_result[..]) but that errors out with Err(Utf8Error { valid_up_to: 0, error_len: Some(1) }) as an error value. This seems weird to me since the hash should be a hexadecimal string, but that's what I observed.
How can I get a valid UTF-8 string from hash_result?
Currently, this results in a value of
GenericArray<u8, _>:However, what I need is not a byte array but a
Stringas output.I tried converting it with
std::str::from_utf8(&hash_result[..])but that errors out withErr(Utf8Error { valid_up_to: 0, error_len: Some(1) })as an error value. This seems weird to me since the hash should be a hexadecimal string, but that's what I observed.How can I get a valid UTF-8 string from
hash_result?