MessageDigest in Rust

189 views Asked by At

I'm not really that strong in cryptography, so I'm striving to understand what this Java code exactly does:

MessageDigest md = MessageDigest.getInstance("SHA-256");
md.update("some string".getBytes("UTF-8"));
byte[] digest = md.digest();

and convert it to Rust.

So how can I do the same thing in Rust, what traits should I use? Is it http://doc.rust-lang.org/rustc/util/sha2/struct.Sha256.html or something else?

1

There are 1 answers

1
Francis Gagné On BEST ANSWER

rustc::util::sha2::Sha256 is part of the Rust compiler and is not meant for external use. You should use the rust-crypto crate instead. Its sha2 module implements SHA-256.