fn key_from_pw(password: &str, salt: pwhash::Salt, derivation: u8) -> Result<aead::Key, ()> {
    let mut key = aead::Key([0; aead::KEYBYTES]);

    match derivation {
        0 => return Ok(key),
        1 => pwhash::derive_key_interactive(&mut key.0, password.as_bytes(), &salt)?,
        2 => pwhash::derive_key_sensitive(&mut key.0, password.as_bytes(), &salt)?,
        _ => {
            e!("Wrong key derivation.");
            exit()
        }
    };

    Ok(key)
}
// Get a key from the password
Get a key from the password
Get a key from the password
fn key_from_pw(password: &str, salt: pwhash::Salt, derivation: u8) -> Result<aead::Key, ()> {
    let mut key = aead::Key([0; aead::KEYBYTES]);
    match derivation {
        0 => return Ok(key),
        1 => pwhash::derive_key_interactive(&mut key.0, password.as_bytes(), &salt)?,
        2 => pwhash::derive_key_sensitive(&mut key.0, password.as_bytes(), &salt)?,
        _ => {
            e!("Wrong key derivation.");
            exit()
        }
    };
    Ok(key)
}
fn key_from_pw ( password : & str , salt : pwhash :: Salt , derivation : u8 ) -> Result < aead :: Key , ( ) > { let mut key = aead :: Key ( [ 0 ; aead :: KEYBYTES ] ) ; match derivation { 0 => return Ok ( key ) , 1 => pwhash :: derive_key_interactive ( & mut key . 0 , password . as_bytes ( ) , & salt ) ? , 2 => pwhash :: derive_key_sensitive ( & mut key . 0 , password . as_bytes ( ) , & salt ) ? , _ => { e ! ( " " ) ; exit ( ) } } ; Ok ( key ) }
Get a key from the password
Get a key from the password
password
&str
salt
pwhash::Salt
derivation
u8