[][src]Crate bao

RepoCrateSpec

This crate implements the Bao hash function and encoding format. The bao command line utility is built on top of it. For more about how Bao works and what the encoding format is doing, see the project README and the full specification.

The encode and decode modules require the std feature, which is enabled by default.

Caution! Not yet suitable for production use. The output of Bao isn't stable. There might be more changes before 1.0.

Example

let expected = "6d1128fa367a8d7f6f8dc946ede523e61b881a8b3463014520ad946dad75f820";
let hash = bao::hash(b"input bytes");
assert_eq!(expected, &hash.to_hex());

let mut hasher = bao::Hasher::new();
hasher.update(b"input");
hasher.update(b" ");
hasher.update(b"bytes");
assert_eq!(hash, hasher.finalize());

Modules

decode

Decode the Bao format, or decode a slice.

encode

Encode some input bytes into the Bao format, or slice an existing encoding.

Structs

Hash

A Bao hash, with constant-time equality.

Hasher

An incremental hasher. Hasher is no_std-compatible and does not allocate. This implementation is single-threaded.

Constants

BUF_SIZE

An efficient buffer size for Hasher, Encoder, Decoder, and SliceDecoder.

HASH_SIZE

The size of a Hash, 32 bytes.

Functions

copy

Copies the entire contents of a reader into a writer, just like std::io::copy, using a buffer size that's more efficient for Hasher, Encoder, Decoder, and SliceDecoder.

hash

Hash a slice of input bytes all at once. If the std feature is enabled, as it is by default, this will use multiple threads via Rayon. Other than initializing the global threadpool, this function doesn't allocate. This is the fastest hashing implementation.