Here you can find the source of generateSalt()
public static byte[] generateSalt()
//package com.java2s; //License from project: Apache License import java.security.SecureRandom; public class Main { private static final int SALT_DEFAULT_SIZE = 32; /**/*from w w w . j av a 2s. co m*/ * Generates secure random bytes. * * @return a secure random salt with a size of {@value #SALT_DEFAULT_SIZE} bytes */ public static byte[] generateSalt() { return generateSalt(SALT_DEFAULT_SIZE); } /** * Generates secure random bytes. * * @param saltSize * the length for the salt in bytes * @return a secure random salt * @since 3.5 */ public static byte[] generateSalt(int saltSize) { SecureRandom r = new SecureRandom(); byte[] salt = new byte[saltSize]; r.nextBytes(salt); return salt; } }