BCrypt.checkpw() Invalid salt version exception

前端 未结 7 1545
一生所求
一生所求 2021-02-05 05:45

I\'m trying to implement authentication using BCrypt, in my Play 2.1. Java application, but I\'m getting Invalid salt version exception when I\'m trying to authenti

7条回答
  •  梦如初夏
    2021-02-05 05:58

    in my case, I have used {bcrypt} as a prefix during the insertion into db.

    instance

    {bcrypt}$2a$12$Yb3YagKV8B3AXoY2p/Ldk.L2maVKfNlr2dedk4ZUs/YUlalS8EzYu
    

    when I retrieve the password the whole value including prefix will be returned. So I have excluded the prefix from the hashing value.

    String prefix= "{bcrypt}";
    
    String hash_pw= user.getPassword().substring((prefix.length());
    
    BCrypt.checkpw(loginRequest.getPassword(),hash_pw);
    

提交回复
热议问题