SecretKeyFactory.getInstance(“PBKDF2WithHmacSHA512”) throws NoSuchAlgorithmException

后端 未结 1 545
遇见更好的自我
遇见更好的自我 2021-01-14 10:28

After a little bit of research and some work I finally was able to hash salt the password now there is a question which is on my mind I have used the SHA1 method and I would

相关标签:
1条回答
  • 2021-01-14 10:55

    That is not possible out of the box

    The OpenJDK implementation does only provide a PBKDF2HmacSHA1Factory.java which has the "HmacSHA1" digest harcoded. As far as I tested, the Oracle JDK is not different in that sense.

    What you have to do is derive the PBKDF2HmacSHA1Factory (come on, it is open!) and add a parameter to its constructor. You may avoid the mess of creating your own Provider, and just initialize and use your factory as follows:

    PBKDF_SecretKeyFactory kf = new PBKDF_SecretKeyFactory("HmacSHA512");
    KeySpec ks = new PBEKeySpec(password,salt,iterations,bitlen);
    byte key[] = kf.engineGenerateSecret(ks).getEncoded();
    
    0 讨论(0)
提交回复
热议问题