Here you can find the source of generateSalt()
public static String generateSalt() throws NoSuchAlgorithmException
//package com.java2s; //License from project: Apache License import javax.crypto.*; import java.security.NoSuchAlgorithmException; public class Main { private static final String AES = "AES"; private static final int KEY_SIZE = 128; private static final int HEX = 16; private static final int BYTE_LEN = 2; public static String generateSalt() throws NoSuchAlgorithmException { KeyGenerator keyGenerator = KeyGenerator.getInstance(AES); keyGenerator.init(KEY_SIZE);/*from w w w .j av a 2 s . co m*/ return byteArrayToHexString(keyGenerator.generateKey().getEncoded()); } private static String byteArrayToHexString(byte[] b) { StringBuilder sb = new StringBuilder(b.length * BYTE_LEN); for (byte aB : b) { int v = aB & 0xff; if (v < HEX) { sb.append('0'); } sb.append(Integer.toHexString(v)); } return sb.toString().toUpperCase(); } }