Crates.io | firebase-scrypt |
lib.rs | firebase-scrypt |
version | 0.2.1 |
source | src |
created_at | 2022-10-02 20:23:06.593045 |
updated_at | 2023-09-08 18:07:11.414269 |
description | Pure Rust implementation of Firebase's script password hashing algorithm |
homepage | https://github.com/Techie-Pi/firebase-scrypt-rust |
repository | https://github.com/Techie-Pi/firebase-scrypt-rust |
max_upload_size | |
id | 678559 |
size | 19,868 |
Pure Rust implementation of Firebase's scrypt password hashing algorithm.
Add this to your Cargo.toml
[dependencies]
firebase-scrypt = "0.2"
With the simple
feature:
use firebase_scrypt::FirebaseScrypt;
const SALT_SEPARATOR: &str = "Bw==";
const SIGNER_KEY: &str = "jxspr8Ki0RYycVU8zykbdLGjFQ3McFUH0uiiTvC8pVMXAn210wjLNmdZJzxUECKbm0QsEmYUSDzZvpjeJ9WmXA==";
const ROUNDS: u32 = 8;
const MEM_COST: u32 = 14;
let firebase_scrypt = FirebaseScrypt::new(SALT_SEPARATOR, SIGNER_KEY, ROUNDS, MEM_COST);
let password = "user1password";
let salt = "42xEC+ixf3L2lw==";
let password_hash ="lSrfV15cpx95/sZS2W9c9Kp6i/LVgQNDNC/qzrCnh1SAyZvqmZqAjTdn3aoItz+VHjoZilo78198JAdRuid5lQ==";
assert!(firebase_scrypt.verify_password(password, salt, password_hash).unwrap())
Use the verify_password
function without FirebaseScrypt
use firebase_scrypt::verify_password;
const SALT_SEPARATOR: &str = "Bw==";
const SIGNER_KEY: &str = "jxspr8Ki0RYycVU8zykbdLGjFQ3McFUH0uiiTvC8pVMXAn210wjLNmdZJzxUECKbm0QsEmYUSDzZvpjeJ9WmXA==";
const ROUNDS: u32 = 8;
const MEM_COST: u32 = 14;
let password = "user1password";
let salt = "42xEC+ixf3L2lw==";
let password_hash ="lSrfV15cpx95/sZS2W9c9Kp6i/LVgQNDNC/qzrCnh1SAyZvqmZqAjTdn3aoItz+VHjoZilo78198JAdRuid5lQ==";
let is_valid = verify_password(
password,
password_hash,
salt,
SALT_SEPARATOR,
SIGNER_KEY,
ROUNDS,
MEM_COST,
).unwrap();
The minimum supported Rust version is: 1.59