How to generate SALT value in Java?

前端 未结 2 1538
無奈伤痛
無奈伤痛 2021-01-31 09:11

What\'s the best way to produce a SALT value in Java as a String that\'s at least 32 bytes long?

2条回答
  •  孤独总比滥情好
    2021-01-31 09:37

    final Random r = new SecureRandom();
    byte[] salt = new byte[32];
    r.nextBytes(salt);
    /** String encodedSalt = Base64.encodeBase64String(salt); */
    

提交回复
热议问题