0
我第一次使用jBCrypt,我沒有在我的項目中使用Spring,也不想爲一個簡單的東西BCrypt使用重型庫。jBCrypt只是將salt加到hash上
我的理解是一個鹽漬散列,涉及鹽與密碼相結合,然後散列它。然而,使用這個庫的結果表明,最終的散列看起來基本上是散列前面的鹽。
這是我的測試代碼:
public static void main(String[] args) throws Exception{
String salt = BCrypt.gensalt();
System.out.println("SALT: " + salt);
String pass = "passwordpasswordpassword";
String hash = BCrypt.hashpw(pass, salt);
System.out.println("HASH: " + hash);
}
這是輸出:
SALT: $2a$10$gJ9JwqTC0jNJEhX3IUl7je
HASH: $2a$10$gJ9JwqTC0jNJEhX3IUl7jeo18wnF1AgMjQha78sFA/c5Mubx49j6q
這只是weirds我出去。我想知道是否我錯誤地使用了庫,或者我只是誤解了BCrypt爲此工作的方式。