easy_password

Crates.ioeasy_password
lib.rseasy_password
version0.1.4
sourcesrc
created_at2018-05-16 09:39:20.627939
updated_at2023-03-03 06:24:31.026323
descriptionEasy password hashing (includes bcrypt)
homepagehttps://github.com/ChrisPWill/easy_password
repositoryhttps://github.com/ChrisPWill/easy_password
max_upload_size
id65660
size8,632
Chris Williams (ChrisPWill)

documentation

README

Easy password hashing

Supported algorithms:

  • Bcrypt

Motivation

Using Bcrypt as is results in passwords being limited to a length of 72. This means it's not easy to salt the password or support arbitrarily long user passwords.

This library performs a HMAC with SHA256 used as the hash function before feeding the result into Bcrypt. As such, any length of password can be used with Bcrypt when passwords are made or verified with this library.

Usage

Hashing a password:

extern crate easy_password;

use easy_password::bcrypt::hash_password;

let bcrypt_rounds = 12; // Secure default
let hash: String =
    hash_password("my_password", b"secure_key", 12).unwrap();

Verifying a hash:

extern crate easy_password;

use easy_password::bcrypt::hash_password;

let success: bool =
    verify_password("test_password", hash.as_str(), b"secure_key").unwrap();

Linting Code

Install clippy:

rustup component add clippy

To lint the code:

cargo clippy

Apply all suggested refactorings (don't forget to reformat code)

Formatting Code

Note: Currently the nightly version of rustfmt is used for formatting purposes only. The project itself is written and tested on the most current version of stable Rust.

To install rustfmt:

rustup component add rustfmt --toolchain nightly

To format the code:

cargo +nightly fmt

License

MIT License, see LICENSE

Commit count: 33

cargo fmt