Struct fog_crypto::hash::Hash [−][src]
Crytographically secure hash of data.
Offers constant time equality check (non-constant time ordinal checks). A version byte is used to indicate what hash algorithm should be used. Uses base58 encoding when displayed, unless overridden with hex formatting or debug formatting.
Supported Versions
- 1: Blake2B hash with 32 bytes of digest
Example
// Create a new hash from raw bytes let hash = Hash::new(b"I am the entire data sequence"); println!("Hash(Base58): {}", hash);
Implementations
impl Hash
[src]
pub fn new(data: impl AsRef<[u8]>) -> Self
[src]
Create a new hash from raw data, using the recommended algorithm.
pub fn with_version(
data: impl AsRef<[u8]>,
version: u8
) -> Result<Self, CryptoError>
[src]
data: impl AsRef<[u8]>,
version: u8
) -> Result<Self, CryptoError>
Create a hash with a specific algorithm version. You should avoid this except when working through a upgrade process, where you may briefly need to support more than one version. Fails if the version isn’t supported.
pub fn version(&self) -> u8
[src]
Algorithm version associated with this hash.
pub fn digest(&self) -> &[u8]
[src]
The raw digest from the hash, without the version byte.
pub fn from_base58(s: &str) -> Result<Self, CryptoError>
[src]
Attempt to parse a Base58-encoded hash type. Fails if the string isn’t valid Base58 or the hash itself isn’t valid.
pub fn to_base58(&self) -> String
[src]
Encode the hash as a Base58 string.
Trait Implementations
impl AsRef<[u8]> for Hash
[src]
impl Clone for Hash
[src]
impl ConstantTimeEq for Hash
[src]
impl Debug for Hash
[src]
impl<'de> Deserialize<'de> for Hash
[src]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
impl Display for Hash
[src]
impl Eq for Hash
[src]
impl Hash for Hash
[src]
fn hash<H: Hasher>(&self, state: &mut H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl LowerHex for Hash
[src]
impl Ord for Hash
[src]
fn cmp(&self, other: &Hash) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl PartialEq<Hash> for Hash
[src]
impl PartialOrd<Hash> for Hash
[src]
fn partial_cmp(&self, other: &Hash) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl Serialize for Hash
[src]
impl TryFrom<&'_ [u8]> for Hash
[src]
type Error = CryptoError
The type returned in the event of a conversion error.
fn try_from(value: &[u8]) -> Result<Self, Self::Error>
[src]
impl UpperHex for Hash
[src]
Auto Trait Implementations
impl RefUnwindSafe for Hash
impl Send for Hash
impl Sync for Hash
impl Unpin for Hash
impl UnwindSafe for Hash
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,