Paranoid-Hash is a rust crate for hashing files, strings, or bytes using a hash function provided by a Rust Library and the hash function provided by the Operating System.
The Library Hash Function that is used is Blake2b with any given digest size between 1 and 64.
The Operating System Hash Function can be either SHA1, SHA256, or SHA512.
A function to compare hash functions is included and attempts to be constant-time.
The hash function returns two strings that are encoded in hexadecimal. You can get the byte representation by using the function decode_from_hex()
.
```rust use paranoid_hash::{ParanoidHash,OsAlgorithm};
fn main(){ // Hash Using Blake2b (32 bytes) and SHA256 let context = ParanoidHash::new(32usize,OsAlgorithm::SHA256); } ```
```rust use paranoid_hash::{ParanoidHash};
fn main(){ // Default Config // [LIB] BLAKE2B_64 // [OS] SHA512 let context = ParanoidHash::default();
// Blake2B and SHA512 Hash Function Returns
let (blake_64,sha512) = context.read("example_file.txt").expect("Failed To Read File");
} ```
```rust use paranoid_hash::{ParanoidHash};
fn main(){ let s: String = String::from("Hello. This string will be hashed");
let context = ParanoidHash::default();
let (blake2b,sha512) = context.read_str(s);
} ```
```rust use paranoid_hash::{ParanoidHash};
fn main(){
let bytes: Vec
let context = ParanoidHash::default();
let (blake2b,sha512) = context.read_bytes(&bytes);
} ```
```rust use paranoid_hash::{ParanoidHash};
fn main(){
let bytes: Vec
let context = ParanoidHash::default();
let (blake2b,sha512) = context.read_bytes(&bytes);
let hash_bytes = ParanoidHash::decode_from_hex(blake2b);
} ```
This is licensed under: