creates a random String in given length

@param length length of the string to create
@return
10717
public static String randomString(int length) {
	StringBuilder sb = new StringBuilder();
	for (int i = 0; i < length; i++) {
	    sb.append(chars[AbstractCaptcha.rnd(0, chars.length - 1)]);
	}
	return sb.toString();
    }
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)])
488851
def random(self, length=22):
        
        random_num = int(binascii.b2a_hex(os.urandom(length)), 16)
        return self._num_to_string(random_num, pad_to_length=length)[:length]
374283
protected function randomString($length)
	{
		$seed = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijqlmnopqrtsuvwxyz0123456789';
		$max = strlen($seed) - 1;
		$string = '';
		for ($i = 0; $i < $length; ++$i) {
			$string .= $seed{intval(mt_rand(0.0, $max))};
		}

		return $string;
	}
1329181
public static String generateNonce(int length) {
        if (length < 0) {
            if (tc.isDebugEnabled()) {
                Tr.debug(tc, "Negative length provided. Will default to nonce of length " + NONCE_LENGTH);
            }
            length = NONCE_LENGTH;
        }
        StringBuilder randomString = new StringBuilder();
        SecureRandom r = new SecureRandom();
        for (int i = 0; i < length; i++) {
            int index = r.nextInt(chars.length);
            randomString.append(chars[index]);
        }
        return randomString.toString();
    }
918178
public static function random($length = 16)
    {
        $string = '';

        while (($len = strlen($string)) < $length) {
            $size = $length - $len;

            $bytes = static::randomBytes($size);

            $string .= substr(str_replace(array('/', '+', '='), '', base64_encode($bytes)), 0, $size);
        }

        return $string;
    }
333583
public static String randomAlphaNumString(int length) {
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < length; i++) {
      sb.append(ALPHANUM.charAt(RANDOM.nextInt(ALPHANUM.length())));
    }
    return sb.toString();
  }
332199
public static String comicChars (int length)
    {
        char[] chars = new char[length];
        for (int ii=0; ii < length; ii++) {
            chars[ii] = RandomUtil.pickRandom(COMIC_CHARS);
        }
        return new String(chars);
    }
873775
def random_string(len)
      rand_max = RAND_CHARS.bytesize
      ret = ""
      len.times{ ret << RAND_CHARS[rand(rand_max)] }
      ret
    end
1114314
public static String createSequence(char c, int length) {
        if (length < 0) length = 1;

        StringBuffer buf = new StringBuffer(length);
        for (; length > 0; length--) {
            buf.append(c);
        }
        return buf.toString();
    }
267356
protected static function generateRandomString($length)
    {
        $characters = static::CHARACTERS;

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

        return $randomString;
    }
765029
def random_string(length, charset):
    
    n = len(charset)
    return ''.join(charset[random.randrange(n)] for _ in range(length))
617823
public static String generate(final int length) {
    final StringBuilder password = new StringBuilder(length);

    double pik = random.nextDouble(); // random number [0,1]
    long ranno = (long) (pik * sigma); // weight by sum of frequencies

    long sum = 0;
    outer:
    for (int c1 = 0; c1 < 26; c1++) {
      for (int c2 = 0; c2 < 26; c2++) {
        for (int c3 = 0; c3 < 26; c3++) {
          sum += get(c1, c2, c3);
          if (sum > ranno) {
            password.append(alphabet.charAt(c1));
            password.append(alphabet.charAt(c2));
            password.append(alphabet.charAt(c3));
            break outer; // Found start.
          }
        }
      }
    }

    // Now do a random walk.
    int nchar = 3;
    while (nchar < length) {
      final int c1 = alphabet.indexOf(password.charAt(nchar - 2));
      final int c2 = alphabet.indexOf(password.charAt(nchar - 1));
      sum = 0;
      for (int c3 = 0; c3 < 26; c3++) {
        sum += get(c1, c2, c3);
      }

      if (sum == 0) {
        break;
      }

      pik = random.nextDouble();
      ranno = (long) (pik * sum);
      sum = 0;
      for (int c3 = 0; c3 < 26; c3++) {
        sum += get(c1, c2, c3);
        if (sum > ranno) {
          password.append(alphabet.charAt(c3));
          break;
        }
      }
      nchar++;
    }
    return password.toString();
  }
519732
public static function randomString($length)
    {
        $key = '';
        $keys = array_merge(range('a', 'z'));

        for ($i = 0; $i < $length; ++$i) {
            $key .= $keys[array_rand($keys)];
        }

        return $key;
    }
834989
public function random_string($length = 32)
    {
        return substr(str_shuffle(str_repeat(
            $x = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
            ceil($length / strlen($x))
        )), 1, $length);
    }
1310910
public static String getStrCode(int length) {
        StringBuffer str = new StringBuffer();
        while (str.length() <= length - 1)
            str.append(strArray[new Random().nextInt(strArray.length)]);
        return str.toString();
    }
169922
def generate_random_string(length=8):
    
    char_set = string.ascii_uppercase + string.digits
    return ''.join(random.sample(char_set * (length - 1), length))