【Rust】uuidとbcryptパスワードハッシュの生成と検証

### uuid

use uuid::Uuid;

fn main() {
    let uuid = Uuid::new_v4().to_hyphenated().to_string();
    println!("{:?}", uuid);
}

Finished `dev` profile [unoptimized + debuginfo] target(s) in 6.75s
Running `target/debug/login`
“f43a4cb0-21dc-4496-8d3d-9100146f043f”

### bcrypt

use pwhash::bcrypt;

fn hashing_password(password: &String) -> String {
    bcrypt::hash(password).unwrap()
}

fn main() {
    let password = "asdf1234".to_string();
    let hash = hashing_password(&password);

    println!("{:?}", hash);
}

Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.37s
Running `target/debug/login`
“$2b$08$3w9c.7T0rGYNa2iUDyzbl.qkyIsVbQp8GCWh1UZzqKNUGoAsRCE/S”

### パスワードの検証(verify)

use pwhash::bcrypt;

fn hashing_password(password: &String) -> String {
    bcrypt::hash(password).unwrap()
}

fn verify(password: &String, hash: &String) -> bool {
    bcrypt::verify(password, hash)
}

fn main() {
    let password = "asdf1234".to_string();
    let hash = hashing_password(&password);

    println!("{:?}", &hash);

    let b = verify(&password, &hash);
    println!("{:?}", &b);
}

warning: `login` (bin “login”) generated 2 warnings (run `cargo fix –bin “login”` to apply 1 suggestion)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.35s
Running `target/debug/login`
“$2b$08$C7NvgIsgqR2Gd3/McnT0IOAYzDF1zXbZrFwNdKNrvKfm2MFqk8h.C”
true

あああ、これこれ
これで、ログイン機能もできそうな気がしてきた^^