Unambiguously digest structured data
udigest
provides utilities for unambiguous hashing the structured data. Structured
data can be anything that implements Digestable
trait:
str
,String
,CStr
,CString
- Integers:
i8
,i16
,i32
,i64
,i128
,u8
,u16
,u32
,u64
,u128
,char
- Containers:
Box
,Arc
,Rc
,Cow
,Option
,Result
- Collections: arrays, slices,
Vec
,LinkedList
,VecDeque
,BTreeSet
,BTreeMap
The trait is intentionally not implemented for certain types:
HashMap
,HashSet
as they can not be traversed in determenistic orderusize
,isize
as their byte size varies on differnet platforms
The Digestable
trait can be implemented for the struct using a macro:
use ;
use Sha256;
let alice = &Person ;
let tag = new;
let hash = udigest;
The crate intentionally does not try to follow any existing standards for unambiguous
encoding. The format for encoding was desingned specifically for udigest
to provide
a better usage experience in Rust. The details of encoding format can be found in
encoding
module.
Features
std
implementsDigestable
trait for types in standard libraryalloc
implementsDigestable
trait for type inalloc
cratederive
enablesDigestable
proc macro