Skip to content

Commit 1455ecd

Browse files
committed
docs: add readme and license
1 parent 6f0a2b6 commit 1455ecd

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Firebase Scrypt (for Rust)
2+
3+
Pure Rust implementation of [Firebase's script](https://github.com/firebase/scrypt) password hashing algorithm.
4+
5+
## Installation
6+
Add this to your ``Cargo.toml``
7+
8+
```toml
9+
[dependencies]
10+
firebase-scrypt = "0.1"
11+
```
12+
13+
## Usage
14+
With the ``simple`` feature:
15+
```rust
16+
use firebase_scrypt::FirebaseScrypt;
17+
18+
const SALT_SEPARATOR: &str = "Bw==";
19+
const SIGNER_KEY: &str = "jxspr8Ki0RYycVU8zykbdLGjFQ3McFUH0uiiTvC8pVMXAn210wjLNmdZJzxUECKbm0QsEmYUSDzZvpjeJ9WmXA==";
20+
const ROUNDS: u32 = 8;
21+
const MEM_COST: u32 = 14;
22+
23+
let firebase_scrypt = FirebaseScrypt::new(SALT_SEPARATOR, SIGNER_KEY, ROUNDS, MEM_COST);
24+
25+
let password = "user1password";
26+
let salt = "42xEC+ixf3L2lw==";
27+
let password_hash ="lSrfV15cpx95/sZS2W9c9Kp6i/LVgQNDNC/qzrCnh1SAyZvqmZqAjTdn3aoItz+VHjoZilo78198JAdRuid5lQ==";
28+
29+
assert!(firebase_scrypt.verify_password(password, salt, password_hash).unwrap())
30+
```
31+
32+
Use the ``verify_password`` function without ``FirebaseScrypt``
33+
```rust
34+
use firebase_scrypt::verify_password;
35+
36+
const SALT_SEPARATOR: &str = "Bw==";
37+
const SIGNER_KEY: &str = "jxspr8Ki0RYycVU8zykbdLGjFQ3McFUH0uiiTvC8pVMXAn210wjLNmdZJzxUECKbm0QsEmYUSDzZvpjeJ9WmXA==";
38+
const ROUNDS: u32 = 8;
39+
const MEM_COST: u32 = 14;
40+
41+
let password = "user1password";
42+
let salt = "42xEC+ixf3L2lw==";
43+
let password_hash ="lSrfV15cpx95/sZS2W9c9Kp6i/LVgQNDNC/qzrCnh1SAyZvqmZqAjTdn3aoItz+VHjoZilo78198JAdRuid5lQ==";
44+
45+
let is_valid = verify_password(
46+
password,
47+
password_hash,
48+
salt,
49+
SALT_SEPARATOR,
50+
SIGNER_KEY,
51+
ROUNDS,
52+
MEM_COST,
53+
).unwrap();
54+
```

0 commit comments

Comments
 (0)