feat: add password-hash

This commit is contained in:
2021-02-11 14:53:25 +08:00
parent bf7b9275c1
commit d383b36f00
4 changed files with 56 additions and 0 deletions

23
__crypto/password-hash/Cargo.lock generated Normal file
View File

@@ -0,0 +1,23 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "base64ct"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22fb38fd6e62e4ceec8543db40ceb714454ff173451a0f2a6c8952fdf39a2d6c"
[[package]]
name = "password-hash"
version = "0.1.0"
dependencies = [
"password-hash 0.1.1",
]
[[package]]
name = "password-hash"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "721a49e14f1803441886c688ba8b653b52e1dcc926969081d22384e300ea4106"
dependencies = [
"base64ct",
]

View File

@@ -0,0 +1,10 @@
[package]
name = "password-hash"
version = "0.1.0"
authors = ["Hatter Jiang@Pixelbook <jht5945@gmail.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
password-hash = "0.1"

View File

@@ -0,0 +1,3 @@
I really DO NOT how to use this crate

View File

@@ -0,0 +1,20 @@
use password_hash::{PasswordHash, ParamsString, Salt, Ident};
fn main() {
let ph = PasswordHash{
algorithm: Ident::new("argon2d"),
version:None,
params:ParamsString::new(),
salt:Some(Salt::new("sample").unwrap()),
hash:None,
};
PasswordHash::generate()
let bs = "hello world".as_bytes();
let bs_len = ph.encoding().encoded_len(bs);
let mut output = vec![0u8; bs_len];
let r = ph.encoding().encode("hello world".as_bytes(), &mut output);
println!("P: {:?}", r);
println!("P: {:?}", output);
}