Here you can find the source of generateSalt()
public static byte[] generateSalt()
//package com.java2s; //License from project: Open Source License import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; public class Main { private static String SALT_ALGORITHM = "SHA1PRNG"; private static int SALT_LENGTH = 8; /**// w ww . j a v a2 s . com * Generates a radom salt * * @return the salt or null in error case */ public static byte[] generateSalt() { try { SecureRandom random = SecureRandom.getInstance(SALT_ALGORITHM); byte[] salt = new byte[SALT_LENGTH]; random.nextBytes(salt); return salt; } catch (final NoSuchAlgorithmException exc) { exc.printStackTrace(); } return null; } }