Hash (HSH) π¦ v0.0.2
HSH
Quantum-Resistant Cryptographic Hash Library for Password Hashing and Verification in Rust π¦
Welcome to HSH π
Website
β’ Documentation
β’ Report Bug
β’ Request Feature
β’ Contributing Guidelines
Overview π
The Hash (HSH) library is a cryptographic hash library for password hashing and verification in Rust, based on the argon2rs
crate.
This library is designed to provide robust security for passwords, utilizing the latest advancements in quantum-resistant cryptography.
It is based on the argon2rs
crate. The library implements a struct named Hash
that provides various methods for password hash generation, retrieval, and verification.
Features β¨
Hash Struct
The Hash
struct has three fields:
password
: A string that stores the plaintext password.hash
: A vector of bytes that stores the hashed password.salt
: A vector of bytes that stores the salt used for password
hashing.
Hash Methods
The Hash
structure provides the following methods for password hashing
and verification:
generate_hash
: A static method that generates a hash from a plaintext password and salt.hash
: A method that returns the hash as a slice of bytes.salt
: A method that returns the salt as a slice of bytes.hash_length
: A method that returns the length of the hash.new
: A constructor method that creates a newHash
struct instance with the given plaintext password and salt.password
: A method that returns the password as a string.password_length
: A method that returns the length of the password.set_password
: A method that sets a new password and generates a new hash.set_hash
: A method that sets a new hash.set_salt
: A method that sets a new salt.from_hash
: A method that creates aHash
struct instance from a given hash.verify
: A method that verifies a plaintext password against the stored hash.to_string_representation
: A method that returns the hash as a string.
Traits
The Hash
struct also implements the following traits:
FromStr
: Allows theHash
struct to be converted from a string.std::fmt::Display
: Allows theHash
struct to be printed as a string.
Macros
The library also provides several macros for common operations on the Hash
struct:
password_length
: Returns the length of the password for a givenHash
struct instance.set_hash
: Sets a new hash value for a givenHash
struct instance.set_password
: Sets a new password and salt value for a givenHash
struct instance.set_salt
: Sets a new salt value for a givenHash
struct instance.generate_hash
: Generates a new hash for a given password and salt.verify_password
: Verifies if the password matches the hash of a givenHash
struct instance.new_hash
: Creates a new instance of theHash
struct with the given password and salt.display_hash
: Prints the hash of a givenHash
struct instance to the console.to_string
: Converts a givenHash
struct instance to a string.
Security and Performance
It is important to note that the library uses the argon2rs
crate for password hashing, which is a secure and quantum-resistant password hashing library.
Installation π¦
It takes just a few minutes to get up and running with hsh
.
Requirements
hsh
requires Rust 1.67.0 or later.
Documentation
βΉοΈ Info: Please check out our website for more information and find our documentation on docs.rs, lib.rs and crates.io.
Usage π
To use hsh
in your project, add the following to your Cargo.toml
file:
[dependencies]
hsh = "0.0.2"
Add the following to your main.rs
file:
extern crate hsh;
use hsh::*;
then you can use the functions in your application code.
Examples
HRC
comes with a set of examples that you can use to get started. The examples are located in the examples
directory of the project. To run the examples, clone the repository and run the following command in your terminal from the project root directory.
cargo run --example hsh
Semantic Versioning Policy π₯
For transparency into our release cycle and in striving to maintain backward compatibility, QRC
follows semantic versioning.
License π
The project is licensed under the terms of both the MIT license and the Apache License (Version 2.0).
Contribution π€
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Acknowledgements π
A big thank you to all the awesome contributors of Mini Functions
for their help and support.
And a special thank you goes to the Rust Reddit community for providing a lot of useful suggestions on how to improve this project.