Struct bc_components::Digest
source · pub struct Digest(_);
Expand description
A cryptographically secure digest, implemented with SHA-256.
Implementations§
source§impl Digest
impl Digest
pub const DIGEST_SIZE: usize = 32usize
sourcepub fn from_data_ref<T>(data: &T) -> Option<Self>where
T: AsRef<[u8]>,
pub fn from_data_ref<T>(data: &T) -> Option<Self>where T: AsRef<[u8]>,
Create a new digest from data.
Returns None
if the data is not the correct length.
sourcepub fn from_image<T>(image: &T) -> Selfwhere
T: AsRef<[u8]>,
pub fn from_image<T>(image: &T) -> Selfwhere T: AsRef<[u8]>,
Create a new digest from the given image.
The image is hashed with SHA-256.
sourcepub fn from_image_parts(image_parts: &[&[u8]]) -> Self
pub fn from_image_parts(image_parts: &[&[u8]]) -> Self
Create a new digest from an array of data items.
The image parts are concatenated and hashed with SHA-256.
sourcepub fn from_digests(digests: &[Digest]) -> Self
pub fn from_digests(digests: &[Digest]) -> Self
Create a new digest from an array of Digests.
The image parts are concatenated and hashed with SHA-256.
sourcepub fn validate<T>(&self, image: &T) -> boolwhere
T: AsRef<[u8]>,
pub fn validate<T>(&self, image: &T) -> boolwhere T: AsRef<[u8]>,
Validate the digest against the given image.
The image is hashed with SHA-256 and compared to the digest.
Returns true
if the digest matches the image.
sourcepub fn from_hex<T>(hex: T) -> Selfwhere
T: AsRef<str>,
pub fn from_hex<T>(hex: T) -> Selfwhere T: AsRef<str>,
Create a new digest from the given hexadecimal string.
Panics
Panics if the string is not exactly 64 hexadecimal digits.
sourcepub fn short_description(&self) -> String
pub fn short_description(&self) -> String
The first four bytes of the digest as a hexadecimal string.
Trait Implementations§
source§impl CBORDecodable for Digest
impl CBORDecodable for Digest
source§impl CBOREncodable for Digest
impl CBOREncodable for Digest
source§impl CBORTagged for Digest
impl CBORTagged for Digest
source§impl CBORTaggedDecodable for Digest
impl CBORTaggedDecodable for Digest
source§fn from_untagged_cbor(cbor: &CBOR) -> Result<Self, Error>
fn from_untagged_cbor(cbor: &CBOR) -> Result<Self, Error>
Creates an instance of this type by decoding it from untagged CBOR.
source§fn from_tagged_cbor(cbor: &CBOR) -> Result<Self, Error>where
Self: Sized,
fn from_tagged_cbor(cbor: &CBOR) -> Result<Self, Error>where Self: Sized,
Creates an instance of this type by decoding it from tagged CBOR.
source§impl CBORTaggedEncodable for Digest
impl CBORTaggedEncodable for Digest
source§fn untagged_cbor(&self) -> CBOR
fn untagged_cbor(&self) -> CBOR
Returns the untagged CBOR encoding of this instance.
source§fn tagged_cbor(&self) -> CBOR
fn tagged_cbor(&self) -> CBOR
Returns the tagged CBOR encoding of this instance.
source§impl Ord for Digest
impl Ord for Digest
source§impl PartialEq<Digest> for Digest
impl PartialEq<Digest> for Digest
source§impl PartialOrd<Digest> for Digest
impl PartialOrd<Digest> for Digest
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl URDecodable for Digest
impl URDecodable for Digest
source§impl UREncodable for Digest
impl UREncodable for Digest
impl Eq for Digest
impl StructuralEq for Digest
impl StructuralPartialEq for Digest
impl URCodable for Digest
Auto Trait Implementations§
impl RefUnwindSafe for Digest
impl Send for Digest
impl Sync for Digest
impl Unpin for Digest
impl UnwindSafe for Digest
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> ToHex for Twhere
T: AsRef<[u8]>,
impl<T> ToHex for Twhere T: AsRef<[u8]>,
source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere U: FromIterator<char>,
Encode the hex strict representing
self
into the result. Lower case
letters are used (e.g. f9b4ca
)source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere U: FromIterator<char>,
Encode the hex strict representing
self
into the result. Upper case
letters are used (e.g. F9B4CA
)