Skip to content

Hash (HSH) πŸ¦€ v0.0.2

Compare
Choose a tag to compare
@github-actions github-actions released this 13 Feb 16:53
d8c008e

HSH

Quantum-Resistant Cryptographic Hash Library for Password Hashing and Verification in Rust πŸ¦€

Made With Rust Crates.io Lib.rs Docs.rs License Codecov

divider

Welcome to HSH πŸ‘‹

HSH Banner

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 new Hash 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 a Hash 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 the Hash struct to be converted from a string.
  • std::fmt::Display: Allows the Hash 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 given Hash struct instance.
  • set_hash: Sets a new hash value for a given Hash struct instance.
  • set_password: Sets a new password and salt value for a given Hash struct instance.
  • set_salt: Sets a new salt value for a given Hash 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 given Hash struct instance.
  • new_hash: Creates a new instance of the Hash struct with the given password and salt.
  • display_hash: Prints the hash of a given Hash struct instance to the console.
  • to_string: Converts a given Hash 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.

divider

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.