create a random string
@return {string}
4370
function randomString() {
    var length = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 8;
    var charset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'abcdefghijklmnopqrstuvwxyz';

    var text = '';
    for (var i = 0; i < length; i++) {
        text += charset.charAt(Math.floor(Math.random() * charset.length));
    }return text;
}
491671
function random(_length) {
    
    var string_length = _length;
    if(string_length < 0)
    	string_length = 1;
    	
    var chars = "0123456789";
    
    var num = '';
    for (var i=0; i<string_length; i++) {
        var rnum = Math.floor(Math.random() * chars.length);
        num += chars.substring(rnum,rnum+1);
    }
    return num*1;
}
727716
function random(min, max, float) {
  if (min === undefined) {
    return Math.random();
  }

  if (max === undefined) {
    max = min;
    min = 0;
  }

  if (max < min) {
    var tmp = max;
    max = min;
    min = tmp;
  }

  if (float) {
    var result = Math.random() * (max - min) + min;
    if (float === true) {
      return result;
    } else if (typeof float === 'number') {
      var str = result.toString();
      var index = str.indexOf('.');
      str = str.substr(0, index + 1 + float);
      if (str[str.length - 1] === '0') {
        str = str.substr(0, str.length - 1) + random(1, 9);
      }
      return parseFloat(str);
    }
  }

  return Math.floor(Math.random() * (max - min + 1) + min);
}
1076664
function randomNode (g) {
  var keys = Object.keys(g)
  return keys[~~(keys.length*Math.random())]
}
177621
public static String random(int count, RandomType randomType) {
		if (count == 0) return "";
		if (count < 0) {
			throw new IllegalArgumentException("Requested random string length " + count + " is less than 0.");
		}
		char[] buffer = new char[count];
		for (int i = 0; i < count; i++) {
			if (randomType.equals(RandomType.INT)) {
				buffer[i] = _INT.charAt(RANDOM.nextInt(_INT.length()));
			} else if (randomType.equals(RandomType.STRING)) {
				buffer[i] = _STR.charAt(RANDOM.nextInt(_STR.length()));
			}else {
				buffer[i] = _ALL.charAt(RANDOM.nextInt(_ALL.length()));
			}
		}
		return new String(buffer);
	}
1259343
private String randomString(String[] s) {
        if (s == null || s.length <= 0) return "";
        return s[this.random.nextInt(s.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))
245174
function random(length, options) {
  length || (length = 8);
  options || (options = {});

  var chars = '';
  var result = '';

  if (options === true) {
    chars = numbers + letters + specials;
  } else if (typeof options == 'string') {
    chars = options;
  } else {
    if (options.numbers !== false) {
      chars += (typeof options.numbers == 'string') ? options.numbers : numbers;
    }

    if (options.letters !== false) {
      chars += (typeof options.letters == 'string') ? options.letters : letters;
    }

    if (options.specials) {
      chars += (typeof options.specials == 'string') ? options.specials : specials;
    }
  }

  while (length > 0) {
    length--;
    result += chars[Math.floor(Math.random() * chars.length)];
  }
  return result;
}
995263
public static function random_string($length) {
        $key = '';
        $keys = array_merge(range(0, 9), range('a', 'z'));

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

        return $key;
    }
902568
function random( width, set ) {
  width = parseInt( width ) || 4
  set   = set || RANDOM_SET

  ass.isString( set, "Random character set must be string" )

  var
    i = 0,
    r = ''

  for ( ; i < width; i ++ )
    r += RANDOM_SET[ Math.floor( Math.random() * RANDOM_SET.length ) ]

  return r
}
1010726
public static String generateRandomKey (Random rand, int length)
    {
        int numKeyChars = KEY_CHARS.length();
        StringBuilder buf = new StringBuilder();
        for (int ii = 0; ii < length; ii++) {
            buf.append(KEY_CHARS.charAt(rand.nextInt(numKeyChars)));
        }
        return buf.toString();
    }
332283
def generate_random_string(number_of_random_chars=8, character_set=string.ascii_letters):
    
    return u('').join(random.choice(character_set)
                      for _ in range(number_of_random_chars))
777011
function Random(opts) {
    Readable.apply(this, arguments);

    if (opts && opts.objectMode) {
        this.objectMode = true;
    }

    this.dictionary = ['1', '0'];
}
1280539
function randstr(options) {
    var opt = _validateOptions(options);
    var from, to;
    if (Array.isArray(opt.length)) {
        _a = opt.length, from = _a[0], to = _a[1];
    }
    else {
        from = to = opt.length;
    }
    var str = '';
    if (0 === to) {
        return str;
    }
    var charsIsString = 'string' === typeof opt.chars;
    var charsLastIndex = charsIsString ? opt.chars.length - 1 : 0;
    var includeControlChars = true === opt.includeControlChars;
    var hasAcceptableFunc = 'function' === typeof opt.acceptable;
    var hasReplacer = 'function' === typeof opt.replacer;
    var max = _randomIntBetween(opt.random, from, to);
    // console.log( 'max', max, 'from', from, 'to', to );
    for (var i = 0, len = 0, charCode = void 0, chr = void 0; i < max && len < max; ++i) {
        if (charsIsString) {
            var index = _randomIntBetween(opt.random, 0, charsLastIndex);
            charCode = opt.chars.charCodeAt(index);
        }
        else {
            charCode = _randomIntBetween(opt.random, opt.chars[0], opt.chars[1]);
        }
        // Non printable?
        if (!includeControlChars && _isControlChar(charCode)) {
            // console.log( 'NOT PRINTABLE!');
            --i; // back to try again
            continue;
        }
        chr = String.fromCharCode(charCode);
        // console.log( 'charCode', charCode, 'char', chr );
        if (hasAcceptableFunc && !opt.acceptable.call(null, chr)) {
            --i; // back to try again
            continue;
        }
        if (hasReplacer) {
            chr = opt.replacer.call(null, chr);
            // console.log( 'char after', chr );
            // Their combined length pass the limit?
            if ((len + chr.length) > max) {
                // console.log( 'greater than max!', 'i', i, 'max', max, 'str', len, 'chr', chr.length );
                --i; // back to try again
                continue;
            }
        }
        str += chr;
        len = str.length;
    }
    return str;
    var _a;
}
949620
def random_string(**kwargs):
    
    n = kwargs.get('length', 10)
    pool = kwargs.get('pool') or string.digits + string.ascii_lowercase
    return ''.join(random.SystemRandom().choice(pool) for _ in range(n))
1160071
function () {
    var text = ''
    var regx = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
    for (var idx = 0; idx < 8; idx++) {
      text = text + regx.charAt(Math.floor(Math.random() * regx.length))
    }
    return text
  }
239685
function makeId(length = RANDOM_CHARACTER_LENGTH) {
    let text = "";
    for (let i = 0; i < length; i++) {
        text += RANDOM_CHARACTER_SOURCE.charAt(Math.floor(Math.random() * RANDOM_CHARACTER_SOURCE.length));
    }

    return text;
}