Return random hex string of a given length
554973
def get_random_hex(length):
    
    if length <= 0:
        return ''
    return hexify(random.randint(pow(2, length*2), pow(2, length*4)))[0:length]
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
156346
def hexdump(src, length=8):
    
    if not src:
        return str(src)
    src = input_validate_str(src, 'src')
    offset = 0
    result = ''
    for this in group(src, length):
        hex_s = ' '.join(["%02x" % ord(x) for x in this])
        result += "%04X   %s\n" % (offset, hex_s)
        offset += length
    return result
374506
def random_unicode(length=20):
    
    def get_char():
        return six.unichr(random.randint(32, 1000))
    chars = u"".join([get_char() for ii in six.moves.range(length)])
    return _join_chars(chars, length)
381423
def random_str(n=20):
    
    return ''.join(random.sample(string.ascii_letters + string.digits, n))
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))
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;
}
815013
def random_string(length=6, alphabet=string.ascii_letters+string.digits):
    
    return ''.join([random.choice(alphabet) for i in xrange(length)])
594644
def get_nonzero_random_bytes(length, rnd=default_crypto_random):
    '''
       
    '''
    result = []
    i = 0
    while i < length:
        rnd = rnd.getrandbits(12*length)
        s = i2osp(rnd, 3*length)
        s = s.replace('\x00', '')
        result.append(s)
        i += len(s)
    return (''.join(result))[:length]
1181055
def cmd(send, msg, args):
    
    match = re.match(r'--(.+?)\b', msg)
    randtype = 'hex'
    if match:
        if match.group(1) == 'int':
            randtype = 'int'
        else:
            send("Invalid Flag.")
            return
    if randtype == 'hex':
        send(hex(getrandbits(50)))
    else:
        maxlen = 1000000000
        msg = msg.split()
        if len(msg) == 2:
            if msg[1].isdigit():
                maxlen = int(msg[1])
            else:
                send("Invalid Length")
                return
        send(str(randrange(maxlen)))
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)])
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')
325964
def random(self, length=4):
        """"""
        if not isinstance(length, int):
            raise TypeError('DigitWord can only be randomized by an integer length')

        if self.wordtype == DigitWord.DIGIT:
            self._word = [Digit(random.randint(0, 9)) for i in range(0, length)]
        elif self.wordtype == DigitWord.HEXDIGIT:
            self._word = [HexDigit(str(hex(random.randint(0, 15))).replace('0x',''))
                          for i in range(0, length)]
        else:
            raise TypeError('wordtype is invalid.')
1342077
function randomHexString(size) {
  if (size === 0) {
    throw new Error('Zero-length randomHexString is useless.');
  }
  if (size % 2 !== 0) {
    throw new Error('randomHexString size must be divisible by 2.');
  }
  return crypto.randomBytes(size / 2).toString('hex');
}
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))
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]
791019
function randomDigits(len) {
  var str = Math.random().toString() + Array(len + 1).join('0');
  return str.substr(2, len);
}