/* Generates a random string from the provided text
550782
public static function generate_rand_for($text = '', $length = 10, $url_friendly = true)
    {
        if (strlen(trim($text)) < 5) {
            $c_array = array_diff(range('a', 'z'), array('y', 'h', 'w', 'q', 'c')) ;
            $text = '0123456789_'.implode('', $c_array);
        }
        if ($url_friendly) {
            $text = preg_replace('/[^a-zA-Z0-9]+/', '', $text);
        }
        $factory = new \RandomLib\Factory;
        $generator = $factory->getLowStrengthGenerator();
        return $generator->generateString($length, $text);
    }
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();
    }
763275
function generator(n) {
  if (!n) return Date.now().toString(36).toUpperCase();
  return Math.random().toString(36).substring(2, 10).toUpperCase();
}
477745
private static String generateRandomAutomaton(Random random) throws IOException {

        final Automaton<?, Integer, ?> automaton;

        if (random.nextBoolean()) {
            automaton = RandomAutomata.randomDFA(random, AUTOMATON_SIZE, INPUT_ALPHABET);
        } else {
            automaton = RandomAutomata.randomMealy(random, AUTOMATON_SIZE, INPUT_ALPHABET, OUTPUT_ALPHABET);
        }

        final StringWriter writer = new StringWriter();

        GraphDOT.write(automaton, INPUT_ALPHABET, writer);

        return writer.toString();
    }
1176919
function createRandomStr(length) {
  const bag = 'abcdefghijklmnopqrstuvwxyz0123456789';
  let generated = '';
  for (let i = 0; i < length; i++) {
    generated += bag[Math.floor(Math.random() * bag.length)];
  }
  return generated;
}
1201121
def scramble_string(self, length):
        """"""
        return fake.text(length) if length > 5 else ''.join([fake.random_letter() for n in range(0, length)])
1263558
function randomString(length, chars) {
  length = length || 8;
  chars = chars || '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  var result = '';
  for (var i = length; i > 0; --i) result += chars[Math.floor(Math.random() * chars.length)];
  return result;
}
815013
def random_string(length=6, alphabet=string.ascii_letters+string.digits):
    
    return ''.join([random.choice(alphabet) for i in xrange(length)])
648172
@Override
    protected String convertBytesToString(final byte[] random) {
        val output = new char[random.length];
        IntStream.range(0, random.length).forEach(i -> {
            val printableCharacters = getPrintableCharacters();
            val index = Math.abs(random[i] % printableCharacters.length);
            output[i] = printableCharacters[index];
        });
        return new String(output);
    }
1039876
public static function getRandomString(
        $intLength,
        $strCharacterSet = self::LETTERS_NUMBERS
    ) {
        // Cast in case there were something else
        $intLength = Type::cast($intLength, Type::INTEGER);
        $strCharacterSet = Type::cast($strCharacterSet, Type::STRING);

        if ($intLength < 1) {
            throw new Caller('Cannot generate a random string of zero length');
        }

        if (strlen(trim($strCharacterSet)) == 0) {
            throw new Caller('Character set must contain at least 1 printable character.');
        }

        return substr(
            str_shuffle(
                str_repeat($strCharacterSet, ceil($intLength / strlen($strCharacterSet)))
            ), 0, $intLength);
    }
1199504
public static String randomNumber(Long length, boolean padding, TestContext context) {
        return new RandomNumberFunction().execute(Arrays.asList(String.valueOf(length), String.valueOf(padding)), context);
    }
599538
private static function generateRandomString($length = 10)
    {
        $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
        $string = '';

        for ($i = 0; $i < $length; $i++) {
            $string .= $characters[rand(0, strlen($characters) - 1)];
        }

        return $string;
    }
660830
public static String randomString(int length, @NonNull CharMatcher validChar) {
      return randomString(length, 0, Integer.MAX_VALUE, validChar);
   }
409126
function random (length) {
  // Guard
  if (length == null) {
    length = DEFAULT;
  } else if (!(typeof length === 'number' && length > 0)) {
    throw new Error('Length should be +ve Number');
  }

  // Fill buffer
  var bits = bitString.randomBits(6 * length);
  return baseURL.encode(bits);
}
1294873
function random(array, len) {
  const size = array.length;
  const randomIndexes = crypto.randomBytes(len).toJSON().data;
  return randomIndexes.map((char) => array[char % size]).join('');
}
425054
function generateRandomClientId() {
    var length = 22;
    var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    var result = '';
    for (var i = length; i > 0; --i) {
        result += chars[Math.round(Math.random() * (chars.length - 1))];
    }
    return result;
}
1037668
def _random_string():
    
    rng = random.SystemRandom()
    token_value = u''.join(rng.choice(CHARSET) for _ in range(CHAR_GROUPS * CHARS_PER_GROUP))
    if CHARS_PER_GROUP > 1:
        return GROUP_SEP.join(map(u''.join, zip(*[iter(token_value)] * CHARS_PER_GROUP)))
    else:
        return token_value