Generates a random id based on `size` and `chars` variable.

        By default it will generate a 16 character long string based on
        ascii uppercase letters and digits.
556966
def _random_id(self, size=16, chars=string.ascii_uppercase + string.digits):
        
        return ''.join(random.choice(chars) for _ in range(size))
946856
public static String randomUUID() {

        String base = CmsUUID.getNullUUID().toString();
        String hexDigits = "0123456789abcdef";
        StringBuffer result = new StringBuffer();
        for (int i = 0; i < base.length(); i++) {
            char ch = base.charAt(i);
            if (ch == '-') {
                result.append(ch);
            } else if (ch == '0') {
                result.append(hexDigits.charAt(Random.nextInt(16)));
            }
        }
        return result.toString();
    }
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))
407396
public function randomId($random_id_length = 10)
    {
        //generate a random id encrypt it and store it in $rnd_id 
        $rnd_id = crypt(uniqid(rand(), 1), uniqid(rand(), 1));

        //to remove any slashes that might have come 
        $rnd_id = strip_tags(stripslashes($rnd_id));

        //Removing any . or / and reversing the string 
        $rnd_id = strrev(str_replace("/", "", str_replace(".", "", $rnd_id)));

        if (strlen($rnd_id) < $random_id_length) {
            $rnd_id = $rnd_id . $this->randomId($random_id_length - strlen($rnd_id));
        }

        //finally I take the first 10 characters from the $rnd_id 
        $rnd_id = substr($rnd_id, 0, $random_id_length);
        $this->BackyardError->log(5, "Random id is " . $rnd_id, array(16));
        return $rnd_id;
    }
66330
def generate_random_string(length=6):
    '''
    
    '''
    n = int(length / 2 + 1)
    x = binascii.hexlify(os.urandom(n))
    s = x[:length]
    return s.decode('utf-8')
7546
public static String makeGUID() {
        String uuid = "";
        String chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
        int rnd = 0;
        int r;

        for (int i = 0; i < GUID_STRING_LENGTH; i += 1) {
            if (i == 8 || i == 13 ||  i == 18 || i == 23) {
                uuid = uuid + "-";
            } else if (i == 14) {
                uuid = uuid + "4";
            } else {
                if (rnd <= 0x02) {
                    rnd = (int) (0x2000000 + Math.round(java.lang.Math.random() * 0x1000000));
                }
                r = rnd & 0xf;
                rnd = rnd >> 4;

                if (i == 19) {
                    uuid = uuid + chars.charAt((r & 0x3) | 0x8);
                } else {
                    uuid = uuid + chars.charAt(r);
                }
            }
        }
        return uuid;
    }
871834
function generateRandomString(length) {
	let s = "";
	let i = length;
	while (length-- > 0) {
		let c = Math.floor(Math.random() * (MAX_HEX_SYMBOL - MIN_HEX_SYMBOL + 1)) + MIN_HEX_SYMBOL;
		c = c.toString(16).toLowerCase();
		s += c;
	}
	return s;
}
294897
def password_generator(length):
    
    return ''.join(random.choice(string.ascii_lowercase + string.digits)
                   for _ in range(length))
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))
628142
def _get_random_string(length=44,
                       allowed_chars='abcdefghijklmnopqrstuvwxyz'
                       'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
                       secret_key=settings.secret_key_bytes()):
    
    secret_key = _ensure_bytes(secret_key)
    _reseed_if_needed(using_sysrandom, secret_key)
    return ''.join(random.choice(allowed_chars) for i in range(length))
863427
def generate_random_long(signed=True):
    """"""
    return int.from_bytes(os.urandom(8), signed=signed, byteorder='little')
74370
def make_random_client_id(self):
        
        if PY2:
            return ('py_%s' %
                    base64.b64encode(str(random.randint(1, 0x40000000))))
        else:
            return ('py_%s' %
                    base64.b64encode(bytes(str(random.randint(1, 0x40000000)),
                                     'ascii')))
1250953
def generate_key(key_length=64):
    
    if hasattr(random, 'SystemRandom'):
        logging.info('Generating a secure random key using SystemRandom.')
        choice = random.SystemRandom().choice
    else:
        msg = "WARNING: SystemRandom not present. Generating a random "\
              "key using random.choice (NOT CRYPTOGRAPHICALLY SECURE)."
        logging.warning(msg)
        choice = random.choice
    return ''.join(map(lambda x: choice(string.digits + string.ascii_letters),
                   range(key_length)))
1029190
def generate_id():
    """"""
    # TODO: Use six.string_type to Py3 compat
    try:
        return unicode(uuid1()).replace(u"-", u"")
    except NameError:
        return str(uuid1()).replace(u"-", u"")
276360
def randstring(length=1):
    
    charstouse = string.ascii_letters + string.digits + string.punctuation
    newpass = ''
    for _ in range(length):
        newpass += str(charstouse[random.randint(0, len(charstouse) - 1)])
    return newpass
73913
def rndstr(size=16, alphabet=""):
    
    rng = random.SystemRandom()
    if not alphabet:
        alphabet = string.ascii_letters[0:52] + string.digits
    return type(alphabet)().join(rng.choice(alphabet) for _ in range(size))
575778
function randomString(_string_length, _mode) {
    
    var string_length = _string_length;
    if(string_length < 3)
    	string_length = 2;
    
    var chars = chars_all;
    
    if(_mode === 'lower_case') chars = chars_lower;
    else if(_mode === 'upper_case') chars = chars_upper;
    else if(_mode === 'nums_oly') chars = chars_nums;
    else if(_mode === 'especials') chars = chars_all + chars_spec;
    
    var str = '';
    for (var i=0; i<string_length; i++) {
        var rnum = Math.floor(Math.random() * chars.length);
        str += chars.substring(rnum,rnum+1);
    }
    
    return str;
}