Generates a random GUID legal string of the given length.

@param {number} len 要生成串的长度

@return {string} 指定长度的16进制数随机串
357470
function rand16Num(len) {
    let result = [];
    for (let i = 0; i < len; i++) {
        result.push('0123456789abcdef'.charAt(
            Math.floor(Math.random() * 16))
        );
    }
    return result.join('');
}
739638
function UINT(max_len) {
        if (typeof max_len === "undefined") { max_len = Number.MAX_VALUE; }
        return _make_alias('UINT', paka.P.UINT, CONCAT(REPEAT(DIGIT(), 1, max_len)));
    }
441481
function(len) {
                    if(len === undefined) len=16;

                    var entropy = fs.randomBytes(len);
                    var result = 0;

                    for(var i=0; i<len; i++) {
                        result = result + Number(entropy[i])/Math.pow(256,(i+1));
                    }
                    return result
                }
252295
function guid(moduleId) {
   var S4 = function() {
      return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
   };
   return moduleId + '@' + (S4()+S4());
}
752737
function generate(length) {
    var len = length - 1;
    var ary = new Array(len);
    for (var i = 0; i < len; i++) {
      ary.push(Math.floor(Math.random() * 10));
    }
    var num = ary.join('');
    return num + '' + checkSum(num);
  }
598158
public static String generateRandomAlphanumericString(Random rnd, int length) {
		checkNotNull(rnd);
		checkArgument(length >= 0);

		StringBuilder buffer = new StringBuilder(length);
		for (int i = 0; i < length; i++) {
			buffer.append(nextAlphanumericChar(rnd));
		}
		return buffer.toString();
	}
169922
def generate_random_string(length=8):
    
    char_set = string.ascii_uppercase + string.digits
    return ''.join(random.sample(char_set * (length - 1), 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))
13068
function uid (length) {
  return new Promise((resolve, reject) => {
    Crypto.randomBytes(length * 2, (err, bytes) => {
      if (err) return reject(err)
      resolve(bytes.toString('base64').replace(/\+/g, '').replace(/\//g, '').replace(/=/g, '').substring(0, 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')
815709
function guid() {
    let curr = (new Date()).valueOf().toString();
    return [
        '4b534c46',  // Fixed first group. and a trick
        rand16Num(4),
        '4' + rand16Num(3),  // The first character of 3rd group is '4'.
        rand16Num(4),
        curr.substring(0, 12)
    ].join('-');
}
101593
public static String randomAsciiRandomLength(int minLength, int maxLength) {
		return RandomStringUtils.random(nextInt(minLength, maxLength), 32, 127, false, false, null,
				threadLocalRandom());
	}
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();
  }
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]
1236140
public static String createRandomNum(int length) {
        if (length < 0) {
            throw new IllegalArgumentException("长度不能小于0");
        }
        char[] chars = new char[length];
        for (int i = 0; i < length; i++) {
            chars[i] = (char) ((Math.random() * 10) + 48);
        }
        return new String(chars);
    }
1275737
function(length) {
    var charset = "abcdef0123456789";
    var i;
    var result = "";
    var isOpera = Object.prototype.toString.call(window.opera) == '[object Opera]';
    if(window.crypto && window.crypto.getRandomValues) {
        values = new Uint32Array(length);
        window.crypto.getRandomValues(values);
        for(i=0; i<length; i++) {
            result += charset[values[i] % charset.length];
        }
        return result;
    } else if(isOpera) {//Opera's Math.random is secure, see http://lists.w3.org/Archives/Public/public-webcrypto/2013Jan/0063.html
        for(i=0; i<length; i++) {
            result += charset[Math.floor(Math.random()*charset.length)];
        }
        return result;
    }
    else throw new Error("Your browser sucks and can't generate secure random numbers");
}
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)])