public static String gensalt(int log_rounds,SecureRandom random){
  if (log_rounds < 4 || log_rounds > 31) {
    throw new IllegalArgumentException("Bad number of rounds");
  }
  StringBuilder rs=new StringBuilder();
  byte rnd[]=new byte[BCRYPT_SALT_LEN];
  random.nextBytes(rnd);
  rs.append("$2a$");
  if (log_rounds < 10) {
    rs.append("0");
  }
  rs.append(log_rounds);
  rs.append("$");
  encode_base64(rnd,rnd.length,rs);
  return rs.toString();
}

public static String gensalt ( int log_rounds , SecureRandom random ) { if ( log_rounds < 4 || log_rounds > 31 ) { throw new IllegalArgumentException ( "Bad number of rounds" ) ; } StringBuilder rs = new StringBuilder ( ) ; byte rnd [ ] = new byte [ BCRYPT_SALT_LEN ] ; random . nextBytes ( rnd ) ; rs . append ( "$2a$" ) ; if ( log_rounds < 10 ) { rs . append ( "0" ) ; } rs . append ( log_rounds ) ; rs . append ( "$" ) ; encode_base64 ( rnd , rnd . length , rs ) ; return rs . toString ( ) ; }
generate a salt for use with the bcrypt . hashpw ( ) method
