I have the following code:
let mut sha256 = Sha256::new();
sha256.update(ip_address);
let ip_address_hash : String = sha256.finalize();
I'm using this Sha2 crate.
I can't seem to figure out how to convert this result to a String.
Error
error[E0308]: mismatched types
--> src/main.rs:37:40
|
37 | let ip_address_hash : String = sha256.finalize();
| ------ ^^^^^^^^^^^^^^^^^ expected struct `std::string::String`, found struct `sha2::digest::generic_array::GenericArray`
| |
| expected due to this
|
= note: expected struct `std::string::String`
found struct `sha2::digest::generic_array::GenericArray<u8, sha2::digest::generic_array::typenum::UInt<sha2::digest::generic_array::typenum::UInt<sha2::digest::generic_array::typenum::UInt<sha2::digest::generic_array::typenum::UInt<sha2::digest::generic_array::typenum::UInt<sha2::digest::generic_array::typenum::UInt<sha2::digest::generic_array::typenum::UTerm, sha2::digest::consts::B1>, sha2::digest::consts::B0>, sha2::digest::consts::B0>, sha2::digest::consts::B0>, sha2::digest::consts::B0>, sha2::digest::consts::B0>>`
finalize()
returns some kind of generic_array, but the documentation of the crate is not clear at all about this...