Hi.

On Tue, 20 Jun 2017 00:12:58 -0400, Wilson MacGyver wrote:
Hi,

After upgrading to commons-lang 3.6 I noticed RandomStringUtils has been
deprecated in favor of RandomStringGenerator in commons-text

currently I'm using it by passing a character array that has a mix of
characters and symbols. I'm also using SecureRandom as the random source

I'm not at all clear on how to do this in RandomStringGenerator.

I notice in the builder you can pass a range, but this implies characters you want to use must be continuous within unicode. The only thing I can
think of is to then
use filteredBy to filter out characters that I don't want?

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


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();


HTH,
Gilles


Thanks


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org

Reply via email to