Struct ssb_crypto::Hash[][src]

#[repr(C)]
pub struct Hash(pub [u8; 32]);
Expand description

A sha256 hash digest. The standard hash in the scuttleverse.

Tuple Fields

0: [u8; 32]

Implementations

The size in bytes of the Hash type ( == 32).

Deserialize from byte representation. Returns None if the slice length isn’t 32. Note that this doesn’t hash the provided byte slice, use the hash function for that.

Deserialize from base-64 string representation. Ignores optional leading ‘%’ or ‘&’ sigil and ‘.sha256’ suffix.

Example

let s = "%4hUgS4j0TwKdsZzOV/tfqiPtqoLw2qYg/Wl9Xy8FPEU=.sha256";
let h = ssb_crypto::Hash::from_base64(s).unwrap();

Does not include “.sha256” suffix or a sigil prefix.

Example

let s = "4hUgS4j0TwKdsZzOV/tfqiPtqoLw2qYg/Wl9Xy8FPEU=";
let h = ssb_crypto::Hash::from_base64(s).unwrap();
assert_eq!(h.as_base64(), s);

Trait Implementations

Get the bytes of this value. Read more

Get the bytes of this value mutably. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.