[][src]Struct b2sum_rust::Blake2bSum

pub struct Blake2bSum { /* fields omitted */ }

Blake2b File Hash Constructor

This is the official constructor used to call the new() function with the parameter of the intended digest size.

Example

use b2sum_rust::Blake2bSum;
 
fn main(){
    // Creates a new File Instance
    let context = Blake2bSum::new(64);
     
    // Outputs a Hexadecimal String
    let hash = context.read("example_file.txt");
 
    // Converts the hexadecimal string to a vector of bytes
    let _bytes = Blake2bSum::to_bytes(&hash);
 
    // Prints The Hexadecimal Representation
    println!("Hash: {}",hash);
 
    // Asserts That These Are Equal
    assert_eq!(hash,"33B20D15383F97EB46D4FA69442596170CCA01008963A7D0E47210C33AEEF991C78323850C012550C227954A40B3D7AD612568ABC73DB9233FAB9EA4F002B0CB");
}
 

Methods

impl Blake2bSum[src]

pub fn new(digest: usize) -> Self[src]

pub fn read<T: AsRef<Path>>(&self, path: T) -> String[src]

Hash File

This is a function that hashes a file using Blake2b and returns the Hexadecimal Representation of it as a String. It takes as input any reference to Path.

It should be noted that changes to the file during hashing, such as truncating the file can cause problems.

pub fn to_bytes(s: &str) -> Vec<u8>[src]

Trait Implementations

impl Debug for Blake2bSum[src]

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]