lib.rs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright (c) 2018, The Tor Project, Inc.
  2. // Copyright (c) 2018, isis agora lovecruft
  3. // See LICENSE for licensing information
  4. //! Common cryptographic functions and utilities.
  5. //!
  6. //! # Hash Digests and eXtendable Output Functions (XOFs)
  7. //!
  8. //! The `digests` module contains submodules for specific hash digests
  9. //! and extendable output functions.
  10. //!
  11. //! ```rust,no_run
  12. //! use crypto::digests::sha2::*;
  13. //!
  14. //! let mut hasher: Sha256 = Sha256::default();
  15. //! let mut result: [u8; 32] = [0u8; 32];
  16. //!
  17. //! hasher.input(b"foo");
  18. //! hasher.input(b"bar");
  19. //! hasher.input(b"baz");
  20. //!
  21. //! result.copy_from_slice(hasher.result().as_slice());
  22. //!
  23. //! assert!(result == [b'X'; DIGEST256_LEN]);
  24. //! ```
  25. #[deny(missing_docs)]
  26. // External crates from cargo or TOR_RUST_DEPENDENCIES.
  27. extern crate digest;
  28. extern crate libc;
  29. extern crate rand_core;
  30. // External dependencies for tests.
  31. #[cfg(test)]
  32. extern crate rand as rand_crate;
  33. // Our local crates.
  34. extern crate external;
  35. #[cfg(not(test))]
  36. #[macro_use]
  37. extern crate tor_log;
  38. pub mod digests; // Unfortunately named "digests" plural to avoid name conflict with the digest crate
  39. pub mod rand;