Skip to content

Instantly share code, notes, and snippets.

@miguelmota
Created November 27, 2018 22:53
Show Gist options
  • Save miguelmota/97b3a46291bc41a9b3054e75609d1dbf to your computer and use it in GitHub Desktop.
Save miguelmota/97b3a46291bc41a9b3054e75609d1dbf to your computer and use it in GitHub Desktop.
Rust sha3 (keccak256) example
[dependencies]
rust-crypto = "0.2"
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