| Crates.io | rcrypt |
| lib.rs | rcrypt |
| version | 0.4.0 |
| created_at | 2022-02-23 04:05:31.685099+00 |
| updated_at | 2022-02-25 03:50:43.518186+00 |
| description | A compact hashing/salting library based on bcrypt with smaller hashes |
| homepage | https://github.com/ohsayan/rcrypt |
| repository | https://github.com/ohsayan/rcrypt |
| max_upload_size | |
| id | 537619 |
| size | 32,190 |
rcrypt: A compact hashing and salting libraryrcrypt, short for "reduced crypt" is a compact hashing and salting library based on bcrypt generating hashes that are 33.3% smaller than bcrypt (40 bytes over 60 bytes).
It was originally made for a part of Skytable's authentication
system storage, but was moved into a separate library for usage in the wider Rust community.
rcrypt is almost a drop-in replacement for the bcrypt crate. Here's how it works.
use rcrypt::DEFAULT_COST;
// your password
let mypass = String::from("pass123");
// hash
let hash = rcrypt::hash(&mypass, DEFAULT_COST).unwrap();
// verify
assert!(rcrypt::verify(&mypass, &hash).unwrap());
The usage remains just the same for users who use the bcrypt crate, except that the hash method returns a Vec<u8> instead of a String, while for the verify method you need to pass a &[u8] for the hash.
If for some reason you need a String with the bcrypt hash from your rcrypt hash, you can do that too!
Here's the procedure:
use rcrypt::DEFAULT_COST;
let rhash = rcrypt::hash("mypassword", DEFAULT_COST).unwrap();
// now let's get the bcrypt hash from the rcrypt hash
let bhash = rcrypt::bmcf::decode_into_mcf(&rhash).unwrap();
The smaller hash sizes result by rcrypt producing binary hashes and merging hash fields, in accordance
with the BMCF spec.
rcryptbcrypt crateThis crate is distributed under the Apache-2.0 License.