inejge / pwhash

A collection of password hashing routines in pure Rust
MIT License
61 stars 11 forks source link

EncodingError, when passing any text #14

Closed legendofmiracles closed 3 years ago

legendofmiracles commented 3 years ago

I am using this library for my sudo replacement, to do all of the passwords stuff, for me. And because i wanted to debug this library, i cloned it, edited some lines, and whenever i pass some text in the unix::verify() function, it always errors with a EncodingError. This is how i call the function:

// format is the id and the password, is a String
let shadow = format!(
        "{}${}${}",
        hash_struct.format, hash_struct.salt, hash_struct.hash
    );
return pwhash::unix::verify(password, &shadow);

I only edited the library, to print the error, and if there's not an error the two values that the contestq function takes. Thanks in advance!

inejge commented 3 years ago

"{}${}${}"

This format won't produce a valid password hash. The hash identifier must start with a '$'.

legendofmiracles commented 3 years ago

That did fix it. Sorry for not noticing that earlier.