Here you can find the source of generateSalt()
public static String generateSalt()
//package com.java2s; //License from project: Open Source License import java.security.SecureRandom; import javax.xml.bind.DatatypeConverter; public class Main { public static String generateSalt() { return random(32); }/*from w w w. j a v a 2 s .co m*/ public static String random(final int length) { final byte[] salt = new byte[length]; new SecureRandom().nextBytes(salt); return hex(salt); } public static String hex(final byte[] bytes) { return DatatypeConverter.printHexBinary(bytes); } public static byte[] hex(final String str) { return DatatypeConverter.parseHexBinary(str); } }