Created
November 27, 2018 22:53
-
-
Save miguelmota/97b3a46291bc41a9b3054e75609d1dbf to your computer and use it in GitHub Desktop.
Rust sha3 (keccak256) example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[dependencies] | |
rust-crypto = "0.2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate crypto; | |
use self::crypto::digest::Digest; | |
use self::crypto::sha3::Sha3; | |
let mut hasher = Sha3::keccak256(); | |
hasher.input_str("abc"); | |
let hex = hasher.result_str(); | |
assert_eq!(hex, "4e03657aea45a94fc7d47ba826c8d667c0d1e6e33a64a036ec44f58fa12d6c45"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment