import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.security.MessageDigest;
import java.security.SecureRandom;
import java.util.Arrays;
public class MainClass {
public static void main(String[] args) throws Exception {
createPassword("password");
}
private static void createPassword(String password) throws Exception {
SecureRandom random = new SecureRandom();
byte[] salt = new byte[12];
random.nextBytes(salt);
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(salt);
md.update(password.getBytes("UTF8"));
byte[] digest = md.digest();
FileOutputStream fos = new FileOutputStream("password");
fos.write(salt);
fos.write(digest);
fos.close();
}
}