SHA-256: Difference between revisions
Content added Content deleted
(Added AWK solution) |
(Use the sha2 crate and split out the hex_string() function, which was misleading in a sha2() function.) |
||
Line 2,152: | Line 2,152: | ||
=={{header|Rust}}== |
=={{header|Rust}}== |
||
<lang rust> |
<lang rust>use sha2::{Digest, Sha256}; |
||
⚫ | |||
use ring::digest::{digest, SHA256}; |
|||
⚫ | |||
} |
|||
fn main() { |
fn main() { |
||
// create a Sha256 object |
|||
⚫ | |||
let mut hasher = Sha256::new(); |
|||
// write input message |
|||
⚫ | |||
// read hash digest and consume hasher |
|||
⚫ | |||
let hex = hex_string(&result); |
|||
assert_eq!( |
|||
hex, |
|||
"764faf5c61ac315f1497f9dfa542713965b785e5cc2f707d6468d7d1124cdfcf" |
|||
); |
|||
println!("{}", hex) |
|||
} |
} |
||
</lang> |
|||
{{out}} |
|||
⚫ | |||
<pre> |
|||
⚫ | |||
764faf5c61ac315f1497f9dfa542713965b785e5cc2f707d6468d7d1124cdfcf |
|||
⚫ | |||
</pre> |
|||
=={{header|Scala}}== |
=={{header|Scala}}== |