#string #encryption #security #tools #secure #performance #salt

rscrypt

rscrypt is a simple, fast, and secure encryption tool written in Rust

9 releases

Uses new Rust 2021

0.1.8 Oct 1, 2022
0.1.7 Oct 1, 2022
0.1.6 Aug 26, 2022
0.1.4 Jul 25, 2022

#503 in Rust patterns

MIT license

8KB
157 lines

🔑 rscrypt

rscrypt is a simple, fast, and secure encryption tool written in Rust.

Usage

Add rscrypt to your Cargo.toml:

[dependencies]
rscrypt = "*"

or install via cargo

cargo add rscrypt

Features

rscrypt contains simple functions for encrypting and decrypting data.

  • gen_salt: Generates a random salt.
  • get_salt: Extracts the salt from the hashed string.
  • get_cost: Extracts the cost from the salt.
  • hash: Hashes a string with a salt.
  • encode: Encodes a string to base64.
  • decode: Decodes a base64 string.
  • compare: compare a string to a hashed string.

Example

use rscrypt::{gen_salt, hash, compare};

fn main() {
    let salt = gen_salt(10);
    let hash = hash(&salt, "password");
    let is_correct = compare("password", &hash);
    println!("{}", is_correct);
}

Dependencies

~1.5–2MB
~52K SLoC