#hash #folder #file #file-hashing

file-hashing

Library for hashing files and folders

3 releases

0.1.2 Dec 22, 2022
0.1.1 Nov 5, 2022
0.1.0 Nov 4, 2022

#1525 in Filesystem

Download history 134/week @ 2024-07-20 161/week @ 2024-07-27 116/week @ 2024-08-03 100/week @ 2024-08-10 93/week @ 2024-08-17 114/week @ 2024-08-24 158/week @ 2024-08-31 85/week @ 2024-09-07 61/week @ 2024-09-14 128/week @ 2024-09-21 94/week @ 2024-09-28 46/week @ 2024-10-05 115/week @ 2024-10-12 159/week @ 2024-10-19 153/week @ 2024-10-26 114/week @ 2024-11-02

561 downloads per month
Used in cli-sandbox

MIT license

16KB
251 lines

file-hashing

This crate will help you easily get hash from files or folders

Example

let path = PathBuf::from("/home/gladi/test-hashing.txt");

let mut hash = Blake2s256::new();
let result = get_hash_file(&path, &mut hash).unwrap();

assert_eq!(result.len(), 64); // Blake2s256 len == 64

P.S. If the examples from the documentation do not work, then you need to look at the unit tests

Motivation

Each time we write our own function to get the hash from a file or folder. We repeat ourselves and violate the DRY principle. With this crate you can save a couple of hours

License: MIT


lib.rs:

This crate will help you easily get hash from files or folders

Example

use std::path::PathBuf;
use blake2::{Blake2s256, Digest};
use file_hashing::get_hash_file;

let path = PathBuf::from("/home/gladi/test-hashing.txt");

let mut hash = Blake2s256::new();
let result = get_hash_file(&path, &mut hash).unwrap();

assert_eq!(result.len(), 64); // Blake2s256 len == 64

P.S. If the examples from the documentation do not work, then you need to look at the unit tests

Dependencies

~2–11MB
~130K SLoC