Skip to main content

Hashing

Enum Hashing 

Source
pub enum Hashing {
    Sha1,
    Sha256,
    Sha384,
    Sha512,
    Sha512_256,
}
Expand description

The hashing algorithm. SHA-1 and SHA-2 algorithms are supported.

Variants§

§

Sha1

The SHA-1 hash algorithm. Should generally be avoided unless working with legacy software.

§

Sha256

The SHA-2 256 bit hash algorithm.

§

Sha384

The SHA-2 384 bit hash algorithm.

§

Sha512

The SHA-2 512 bit hash algorithm.

§

Sha512_256

The SHA-2 512_256 bit hash algorithm. Uses SHA-512 but returns only 256 bits.

Implementations§

Source§

impl Hashing

Source

pub fn new_context(&self) -> HashContext

Creates a new instance of a HashContext to be used with the selected Hashing algorithm.

Source

pub fn hash(&self, data: &[u8]) -> Hash

Returns a Hash of the given byte array data.

Source

pub fn hash_vec(&self, data: Vec<u8>) -> Hash

Returns a Hash of the given byte vector data.

Source

pub fn hash_str(&self, data: &str) -> Hash

Returns a Hash of the given string data.

Source

pub fn hash_file(&self, path: &str) -> Result<Hash, Error>

Returns a Result<Hash, Error> containing the Hash of the file located at the given path on success, otherwise returns a std::io::Error if the file doesn’t exist or can’t be opened in read-only mode.

Trait Implementations§

Source§

impl Debug for Hashing

Source§

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

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

impl Eq for Hashing

Source§

impl PartialEq for Hashing

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Hashing

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.