/** * Generate secure random salt data to use with hash algorithm * @return Secure random salt data */ public static byte[] generateSalt() { return generateSalt(DEFAULT_SALT_BYTES_SIZE); }
/** * Perform hashing on given String <code>source</code>. UTF-8 encoding is used for source to bytes conversion. * @param algorithmName Hash algorithm to use * @param source Source string * @param salt Optional salt * @param iterations Hash iterations to perform * @return Hashed source as bytes array * @throws NoSuchAlgorithmException Hash algorithm is not available in the environment */ public static byte[] hash(String algorithmName, String source, byte[] salt, int iterations) throws NoSuchAlgorithmException { return hash(algorithmName, ConversionUtils.toBytes(source), salt, iterations); }