Here you can find the source of generateSalt(int numBytes)
public static byte[] generateSalt(int numBytes)
//package com.java2s; /**/*w w w. j ava 2 s . c om*/ * Copyright (c) 2005-2012 springside.org.cn * * Licensed under the Apache License, Version 2.0 (the "License"); */ import java.security.SecureRandom; public class Main { private static SecureRandom random = new SecureRandom(); public static byte[] generateSalt(int numBytes) { if (numBytes <= 0) { throw new IllegalArgumentException(String .format("numBytes argument must be a positive integer (1 or larger)", Long.valueOf(numBytes))); } byte[] bytes = new byte[numBytes]; random.nextBytes(bytes); return bytes; } }