【发布时间】:2021-03-21 03:33:51
【问题描述】:
我正在测试 sha2 crate (https://docs.rs/sha2/0.9.3/sha2/)
let base2: i32 = 2;
let total_size = base2.pow(24);
let mut data = vec![0u8;total_size as usize];
let mut hasher = Sha256::new();
hasher.update(data);
let result = hasher.finalize();
println!("sha256 before write: {}", result);
但是我无法打印结果:
error[E0277]: `GenericArray<u8, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>>` doesn't implement `std::fmt::Display`
--> src/sha_check.rs:60:41
|
60 | println!("sha256 before write: {}", result);
| ^^^^^^ `GenericArray<u8, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>>` cannot be formatted with the default formatter
如何转储GenericArray?
我试图找到.finalize(),但我不知道它来自哪里。
【问题讨论】:
-
SHA256 会产生一系列原始字节,您正在尝试将它们打印到(文本)终端。您希望在屏幕上看到什么?
标签: rust