Use a cryptograhically-secure Pseudorandom number generator for picking
        a combination of letters, digits, and punctuation to be our secret.

        :param length: how long to make the secret (12 seems ok most of the time)
164131
def _create_secret(self, length=12):
        
        # Charset will have 64 +- characters
        charset = string.digits + string.ascii_letters + '+-'
        return "".join(random.SystemRandom().choice(charset) for _ in
                range(length))
235236
def generate_secret(length=30):
    
    rand = random.SystemRandom()
    ascii_characters = string.ascii_letters + string.digits

    return ''.join(rand.choice(ascii_characters) for _ in range(length))
863716
public static String randomAsciiFixLength(int length) {
		return RandomStringUtils.random(length, 32, 127, false, false, null, threadLocalRandom());
	}
666668
def generate_secret
      if defined?(SecureRandom)
        SecureRandom.urlsafe_base64(32)
      else
        Base64.encode64(
          Digest::SHA256.digest("#{Time.now}-#{Time.now.usec}-#{$$}-#{rand}")
        ).gsub('/','-').gsub('+','_').gsub('=','').strip
      end
    end
1058702
def gen_random_string(str_len):
    
    return ''.join(
        random.choice(string.ascii_letters + string.digits) for _ in range(str_len))
473925
def generate_secret(length=32):
  
  alphabet = string.ascii_letters + string.digits
  random_bytes = os.urandom(length)
  indices = [int(len(alphabet) * (ord(byte) / 256.0)) for byte in random_bytes]
  return "".join([alphabet[index] for index in indices])
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)])
8653
def random_secret() -> Secret:
    
    while True:
        secret = os.urandom(32)
        if secret != constants.EMPTY_HASH:
            return Secret(secret)
862847
def create_random_string(length=7, chars='ABCDEFGHJKMNPQRSTUVWXYZ23456789',
                         repetitions=False):
    
    if repetitions:
        return ''.join(random.choice(chars) for _ in range(length))
    return ''.join(random.sample(chars, length))
1209802
def _ensure_length(encoded, min_length, alphabet, guards, values_hash):
    """"""
    len_guards = len(guards)
    guard_index = (values_hash + ord(encoded[0])) % len_guards
    encoded = guards[guard_index] + encoded

    if len(encoded) < min_length:
        guard_index = (values_hash + ord(encoded[2])) % len_guards
        encoded += guards[guard_index]

    split_at = len(alphabet) // 2
    while len(encoded) < min_length:
        alphabet = _reorder(alphabet, alphabet)
        encoded = alphabet[split_at:] + encoded + alphabet[:split_at]
        excess = len(encoded) - min_length
        if excess > 0:
            from_index = excess // 2
            encoded = encoded[from_index:from_index+min_length]

    return encoded
1201121
def scramble_string(self, length):
        """"""
        return fake.text(length) if length > 5 else ''.join([fake.random_letter() for n in range(0, length)])
622864
def random(self, length=None):
        
        if length is None:
            length = self._length

        random_num = int(binascii.b2a_hex(os.urandom(length)), 16)
        return int_to_string(random_num, self._alphabet, padding=length)[:length]
1096163
public static String randomString(int length) {
        Preconditions.checkArgument(length > MIN_PASSWORD_LENGTH, "random string length must be at least 1 character");
        Preconditions.checkArgument(length <= MAX_PASSWORD_LENGTH, "random string length must be at most 256 character");
        
        return RandomStringUtils.random(length, 0, CHARACTERS.length-1, false, false, CHARACTERS, new SecureRandom());
    }
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();
    }
447686
def generate_random_token(length=32):
    
    chars = (string.ascii_lowercase + string.ascii_uppercase + string.digits)
    return ''.join(random.choice(chars) for _ in range(length))
558987
function generateRandomId (length) {
  var str = ''
  length = length || 6
  while (str.length < length) {
    str += (((1 + Math.random()) * 0x10000) | 0).toString(16)
  }
  return str.substring(str.length - length, str.length)
}
1260359
def __generate_string(length):  # pragma: no cover
        """"""
        return ''.join(
            SystemRandom().choice(string.ascii_letters + string.digits)
            for x in range(length)).encode()