Skip to main content

SHA2_256_Portable

Struct SHA2_256_Portable 

Source
pub struct SHA2_256_Portable { /* private fields */ }
Expand description

A portable implementation of the SHA2-256 algorithm.

This implementation is portable, will work on any platform and is const friendly.

§Notes

The concrete algorithm follows closely the SHA2-256 specification taken from RFC 4634.

Implementations§

Source§

impl SHA2_256_Portable

Source

pub const fn new() -> Self

Creates a new SHA2_256_Portable instance.

Source

pub const fn update_const(&mut self, data: &[u8])

Writes a block of data to the underlying state.

§Panics

This function will panic if the length of the data is greater than u32::MAX, and when the total processed length exceeds u64::MAX.

Source

pub const fn write_result_const(&self, output: &mut [u8; 32])

Writes the final has value to the passed output.

§Notes

This function does not update the internal state, and thus the SHA2_256_Portable can still be used afterwards.

Source

pub const fn result_const(&self) -> [u8; 32]

Returns the final hash value.

§Notes

This function does not update the internal state, and thus the SHA2_256_Portable can still be used afterwards.

Trait Implementations§

Source§

impl Default for SHA2_256_Portable

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<SHA2_256_Portable> for SHA2_256_aarch64

Source§

fn from(portable: SHA2_256_Portable) -> Self

Converts to this type from the input type.
Source§

impl From<SHA2_256_Portable> for SHA2_256_x86

Source§

fn from(portable: SHA2_256_Portable) -> Self

Converts to this type from the input type.
Source§

impl From<SHA2_256_aarch64> for SHA2_256_Portable

Source§

fn from(x86: SHA2_256_aarch64) -> Self

Converts to this type from the input type.
Source§

impl From<SHA2_256_x86> for SHA2_256_Portable

Source§

fn from(x86: SHA2_256_x86) -> Self

Converts to this type from the input type.
Source§

impl HashFunction for SHA2_256_Portable

Source§

type Output = [u8; 32]

Source§

fn update(&mut self, data: impl AsRef<[u8]>)

Updates the internal state of the HashFunction with given data.
Source§

fn write_result(&self, output: &mut Self::Output)

Writes the final result to the output passed as ref parameter.
Source§

fn result(&self) -> Self::Output

A wrapper around HashFunction::write_result that returns the hash instead of writing it to output parameter.
Source§

impl ReprC for SHA2_256_Portable

Source§

const CHECK: ()

This field is used for const checks only.

Auto Trait Implementations§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.