public static String gensalt(int log_rounds, SecureRandom random) {
        if (log_rounds < MIN_LOG_ROUNDS || log_rounds > MAX_LOG_ROUNDS) {
            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();
    }
@PrepareForTest({BCrypt.class, SecureRandom.class})
    @Test
    public void testGensalt() throws Exception {
        PowerMockito.whenNew(SecureRandom.class).withNoArguments()
                .thenReturn(PowerMockito.mock(SecureRandom.class));
        Assert.assertEquals("$2a$10$......................", BCrypt.gensalt());
        Assert.assertEquals("$2a$09$......................", BCrypt.gensalt(9));
    }