Struct chksum_hash_sha2_384::Digest

source ·
pub struct Digest(/* private fields */);
Expand description

A hash digest.

Check digest module for usage examples.

Implementations§

source§

impl Digest

source

pub const fn new(digest: [u8; 48]) -> Self

Creates a new digest.

source

pub const fn as_bytes(&self) -> &[u8]

Returns a byte slice of the digest’s contents.

source

pub fn into_inner(self) -> [u8; 48]

Consumes the digest, returning the digest bytes.

source

pub fn to_hex_lowercase(&self) -> String

Returns a string in the lowercase hexadecimal representation.

§Example
use chksum_hash_sha2_384 as sha2_384;

let digest = [
    0x38, 0xB0, 0x60, 0xA7,
    0x51, 0xAC, 0x96, 0x38,
    0x4C, 0xD9, 0x32, 0x7E,
    0xB1, 0xB1, 0xE3, 0x6A,
    0x21, 0xFD, 0xB7, 0x11,
    0x14, 0xBE, 0x07, 0x43,
    0x4C, 0x0C, 0xC7, 0xBF,
    0x63, 0xF6, 0xE1, 0xDA,
    0x27, 0x4E, 0xDE, 0xBF,
    0xE7, 0x6F, 0x65, 0xFB,
    0xD5, 0x1A, 0xD2, 0xF1,
    0x48, 0x98, 0xB9, 0x5B,
];
let digest = sha2_384::Digest::new(digest);
assert_eq!(
    digest.to_hex_lowercase(),
    "38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b"
);
source

pub fn to_hex_uppercase(&self) -> String

Returns a string in the uppercase hexadecimal representation.

§Example
use chksum_hash_sha2_384 as sha2_384;

let digest = [
    0x38, 0xB0, 0x60, 0xA7,
    0x51, 0xAC, 0x96, 0x38,
    0x4C, 0xD9, 0x32, 0x7E,
    0xB1, 0xB1, 0xE3, 0x6A,
    0x21, 0xFD, 0xB7, 0x11,
    0x14, 0xBE, 0x07, 0x43,
    0x4C, 0x0C, 0xC7, 0xBF,
    0x63, 0xF6, 0xE1, 0xDA,
    0x27, 0x4E, 0xDE, 0xBF,
    0xE7, 0x6F, 0x65, 0xFB,
    0xD5, 0x1A, 0xD2, 0xF1,
    0x48, 0x98, 0xB9, 0x5B,
];
let digest = sha2_384::Digest::new(digest);
assert_eq!(
    digest.to_hex_uppercase(),
    "38B060A751AC96384CD9327EB1B1E36A21FDB71114BE07434C0CC7BF63F6E1DA274EDEBFE76F65FBD51AD2F14898B95B"
);

Trait Implementations§

source§

impl AsRef<[u8]> for Digest

source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Clone for Digest

source§

fn clone(&self) -> Digest

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Digest

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Digest for Digest

source§

fn as_bytes(&self) -> &[u8]
where Self: AsRef<[u8]>,

Returns the digest as a byte slice.
source§

fn to_hex_lowercase(&self) -> String
where Self: LowerHex,

Returns the digest as a lowercase hexadecimal string.
source§

fn to_hex_uppercase(&self) -> String
where Self: UpperHex,

Returns the digest as an uppercase hexadecimal string.
source§

impl Display for Digest

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<[u8; 48]> for Digest

source§

fn from(digest: [u8; 48]) -> Self

Converts to this type from the input type.
source§

impl From<Digest> for [u8; 48]

source§

fn from(digest: Digest) -> Self

Converts to this type from the input type.
source§

impl LowerHex for Digest

source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter.
source§

impl PartialEq for Digest

source§

fn eq(&self, other: &Digest) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl TryFrom<&str> for Digest

§

type Error = FormatError

The type returned in the event of a conversion error.
source§

fn try_from(digest: &str) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl UpperHex for Digest

source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter.
source§

impl Copy for Digest

source§

impl Eq for Digest

source§

impl StructuralPartialEq for Digest

Auto Trait Implementations§

§

impl Freeze for Digest

§

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.