public String generateRandomCandidate ( Random rng ) { char [ ] chars = new char [ stringLength ] ; for ( int i = 0 ; i < stringLength ; i ++ ) { chars [ i ] = alphabet [ rng . nextInt ( alphabet . length ) ] ; } return new String ( chars ) ; }
Generates a random string of a pre - configured length . Each character is randomly selected from the pre - configured alphabet . The same character may appear multiple times and some characters may not appear at all .