Here you can find the source of generateSalt()
Parameter | Description |
---|---|
NoSuchAlgorithmException | an exception |
public static byte[] generateSalt() throws NoSuchAlgorithmException
//package com.java2s; //License from project: Open Source License import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; public class Main { private static final int SALT_BYTE_SIZE = 24; /**/*from w w w. jav a 2s . c om*/ * This method used to generate salt * @return * @throws NoSuchAlgorithmException */ public static byte[] generateSalt() throws NoSuchAlgorithmException { SecureRandom random = new SecureRandom(); byte[] salt = new byte[SALT_BYTE_SIZE]; random.nextBytes(salt); return salt; } }