diff options
Diffstat (limited to 'src/rust/crypto/lib.rs')
-rw-r--r-- | src/rust/crypto/lib.rs | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/rust/crypto/lib.rs b/src/rust/crypto/lib.rs index e7e3b22e03..d120635b95 100644 --- a/src/rust/crypto/lib.rs +++ b/src/rust/crypto/lib.rs @@ -10,18 +10,18 @@ //! and extendable output functions. //! //! ``` -//! use crypto::digests::sha256::Sha256; +//! use crypto::digests::sha2::*; //! -//! let hasher: Sha256 = Sha256::default(); +//! let mut hasher: Sha256 = Sha256::default(); //! let mut result: [u8; 32] = [0u8; 32]; //! -//! hasher.input("foo"); -//! hasher.input("bar"); -//! hasher.input("baz"); +//! hasher.input(b"foo"); +//! hasher.input(b"bar"); +//! hasher.input(b"baz"); //! -//! result.copy_from_slice(hasher.result().as_bytes()); +//! result.copy_from_slice(hasher.result().as_slice()); //! -//! assert!(result == "XXX"); +//! assert!(result == [b'X'; DIGEST256_LEN]); //! ``` #[deny(missing_docs)] @@ -29,9 +29,18 @@ // External crates from cargo or TOR_RUST_DEPENDENCIES. extern crate digest; extern crate libc; +extern crate rand_core; + +// External dependencies for tests. +#[cfg(test)] +extern crate rand as rand_crate; // Our local crates. extern crate external; +#[cfg(not(test))] +#[macro_use] +extern crate tor_log; pub mod digests; // Unfortunately named "digests" plural to avoid name conflict with the digest crate +pub mod rand; |