What's the best way to produce a SALT value in Java as a String that's at least 32 bytes long?
在Java中生成SALT值作为至少32字节长的字符串的最佳方法是什么?
2 个解决方案
#1
43
final Random r = new SecureRandom();
byte[] salt = new byte[32];
r.nextBytes(salt);
/** String encodedSalt = Base64.encodeBase64String(salt); */
#2
2
In SpringSecurity you can use org.springframework.security.crypto.keygen.KeyGenerators
在SpringSecurity中,您可以使用org.springframework.security.crypto.keygen.KeyGenerators
#1
43
final Random r = new SecureRandom();
byte[] salt = new byte[32];
r.nextBytes(salt);
/** String encodedSalt = Base64.encodeBase64String(salt); */
#2
2
In SpringSecurity you can use org.springframework.security.crypto.keygen.KeyGenerators
在SpringSecurity中,您可以使用org.springframework.security.crypto.keygen.KeyGenerators