On Tue, Jun 20, 2017 at 8:22 AM, Gilles <[email protected]>
wrote:

> Hi.
>
>
> That would not be very efficient.
> Perhaps we should implement a "selectFrom" feature:
>   RandomStringGenerator gen = new RandomStringGenerator.Builder()
>     .selectFrom(charArray)
>     .build();



that would be great. I would imagine using this as password generator is a
pretty common use case. Limiting passwords to allowed character list is a
fairly standard practice.

>
>
>
>> At first glance, it also looks like usingRandom() only works with the
>> apache common RNG?
>>
>
> No. You can pass any class that implement the "TextRandomProvider"
> interface (there is an example in the "RandomStringGeneratorTest"
> unit test class).
>
> If you use Java 8, you can also do:
>   final SecureRandom rand = new SecureRandom();
>   RandomStringGenerator gen = new RandomStringGenerator.Builder()
>     .usingRandom(rand::nextInt)
>     .build();
>
>
>
ah, I see. need to pass nextInt. got it. Thank you very much for that.



>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>


-- 
Omnem crede diem tibi diluxisse supremum.

Reply via email to