Generate a random String

@param values The characters list to use in the randomization
@param len The number of characters in the output String
@return The randomized String
967819
public static String randomString( char[] values, int len )
    {
        Random rnd = new SecureRandom();
        StringBuilder sb = new StringBuilder( len );
        for ( int i = 0; i < len; i++ ) {
            sb.append( values[ rnd.nextInt( values.length )] );
        }
        return sb.toString();
    }
386274
public static String randomString(Long numberOfLetters, String notationMethod, boolean useNumbers, TestContext context) {
        return new RandomStringFunction().execute(Arrays.asList(String.valueOf(numberOfLetters), notationMethod, String.valueOf(useNumbers)), context);
    }
1024998
public String randomString(String permitted, int length) {
        StringBuilder result = new StringBuilder(length);
        int maxIndex = permitted.length();
        for (int i = 0; i < length; i++) {
            int index = random(maxIndex);
            char value = permitted.charAt(index);
            result.append(value);
        }
        return result.toString();
    }
836264
public final static byte[] encode(long[] values) throws IOException {
    LongTermsSet termsSet = new LongTermsSet(values.length, new NoopCircuitBreaker("<term_set>"));
    for (int i = 0; i < values.length; i++) {
      termsSet.add(values[i]);
    }
    return termsSet.writeToBytes().bytes;
  }
954805
def random_string(length, numeric_only=False):
    
    choices = string.digits if numeric_only else string.ascii_uppercase + string.digits
    return ''.join(random.choice(choices) for _ in range(length))
129277
public String generateRandomToken(int length) {
        final char[] token = new char[length];

        for (int i = 0; i < length; i++) {
            final int tokenIndex = random.nextInt(this.tokenChars.length);
            token[i] = tokenChars[tokenIndex];
        }

        return new String(token);
    }
618723
public static long generate(long crc, String value)
  {
    if (value == null) {
      return crc;
    }
    
    int len = value.length();

    for (int i = 0; i < len; i++) {
      char ch = value.charAt(i);

      if (ch > 0xff) {
        crc = next(crc, (ch >> 8));
      }

      crc = next(crc, ch);
    }

    return crc;
  }
1189629
public static String randomNumberString(int length) {
        char[] chars = "0123456789".toCharArray();
        return RandomStringUtils.random(length, 0, 9, false, false, chars);
    }
993241
public static String getRandomString(final int stringLength) {

    StringBuilder stringBuilder = getStringBuild();
    for (int i = 0; i < stringLength; i++) {
      stringBuilder.append(getRandomAlphabetic());
    }
    return stringBuilder.toString();
  }
1022676
private static final String randomString(final Random random) {
		final byte[] bytes = new byte[RANDOM_BYTES_LENGTH];
		random.nextBytes(bytes);
		return StringUtils.byteToHexString(bytes);
	}
1294873
function random(array, len) {
  const size = array.length;
  const randomIndexes = crypto.randomBytes(len).toJSON().data;
  return randomIndexes.map((char) => array[char % size]).join('');
}
728170
public static List random(long minLen, long maxLen, Object... values) {
		long len = randomLong(minLen, maxLen);
		if (len > 0) {
			List ret = new ArrayList();
			for (int i = 0; i < len; i++) {
				ret.add(randomOne(values));
			}
			return ret;
		}
		return null;
	}
1138245
def generate_random_string(cls, length):
        
        # avoid things that could be mistaken ex: 'I' and '1'
        letters = "23456789ABCDEFGHJKLMNPQRSTUVWXYZ"
        return "".join([random.choice(letters) for _ in range(length)])
715941
public static function randStr($len = 6)
    {
        $chars = str_repeat('0123456789', $len);
        $chars = str_shuffle($chars);
        $str   = substr($chars, 0, $len);
        return $str;
    }
1316119
public static String rand(int size) {
        StringBuilder num = new StringBuilder();
        for (int i = 0; i < size; i++) {
            double a = Math.random() * 9;
            a = Math.ceil(a);
            int randomNum = new Double(a).intValue();
            num.append(randomNum);
        }
        return num.toString();
    }
1214671
public static void shuffle (Object[] values, Random rnd)
    {
        shuffle(values, 0, values.length, rnd);
    }
976629
public static String shuffle(final String value) {
        validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER);
        String[] chars = chars(value);
        Random random = new Random();
        for (int i = 0; i < chars.length; i++) {
            int r = random.nextInt(chars.length);
            String tmp = chars[i];
            chars[i] = chars[r];
            chars[r] = tmp;
        }
        return Arrays.stream(chars).collect(joining());
    }