Generate an alphanumeric ID with the given length.
@param  {Integer} length
@return {String}        ID
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)
}
719506
protected function keygen($length)
	{
		$token = '';
		$tokenlength = round($length * 4 / 3);

		for ($i = 0; $i < $tokenlength; ++$i) {
			$token .= chr(rand(32,1024));
		}

		$token = base64_encode(str_shuffle($token));

		return substr($token, 0, $length);
	}
1038117
function generateId () {
    var now = Date.now()
    if (now <= this.lastTime) {
      now = this.lastTime
      this.sequence += 1
    } else {
      this.lastTime = now
      this.sequence = 0
    }
    return now + ' ' + this.nodeId + ' ' + this.sequence
  }
1346229
function pad(value, length) {
		value = '' + value;
		return '000000'.substring(0, length - value.length) + value;
	}
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);
  }
73064
function getPseudoUUID() {
  var chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
  var len = chars.length;
  var ret = [];

  for (var i = 0; i < 10; i++) {
    ret.push(chars[Math.floor(Math.random() * len)]);
  }
  return ret.join('');
}
209754
function createObjectId() {
    var
        s = Math.floor(Math.random() * 0xffffffff).toString(16),
        padding = 8 - s.length;
    while (padding > 0) {
        s = '0' + s;
        padding--;
    }
    return s;
}
323351
public static String generatePassword(int length)
  {
    Params.strictPositive(length, "Password length");
    StringBuilder password = new StringBuilder(length);
    Random random = new Random();

    for(int i = 0; i < length; i++) {
      String charCategory = PASSWORD_DICTIONARY[random.nextInt(PASSWORD_DICTIONARY.length)];
      int position = random.nextInt(charCategory.length());
      password.append(charCategory.charAt(position));
    }
    return new String(password);
  }
129216
function intToID(num) {
  var idName = '';
  while (num > 0) {
    num--;
    idName = String.fromCharCode((num % 26) + 'a'.charCodeAt(0)) + idName;
    num = Math.floor(num / 26)
  }
  return idName;
}
1192886
function getLengthOfLength(lenValue, indefiniteLength) {
  var lenOfLen;
  
  if (indefiniteLength) {
    lenOfLen = 3;
  } else if (lenValue > 0x00FFFFFF) {
    lenOfLen = 5;
  } else if (lenValue > 0x0000FFFF) {
    lenOfLen = 4;
  } else if (lenValue > 0x000000FF) {
    lenOfLen = 3;
  } else if (lenValue > 0x0000007F) {
    lenOfLen = 2; 
  } else {
    lenOfLen = 1;
  }
  
  return lenOfLen
}
953491
function generateKey(length) {
    const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
    const possibleLength = possible.length - 1;

    let text = '';
    _.times(getNumber(length, 16), () => {
        text += possible.charAt(_.random(possibleLength));
    });

    return text;
}
83205
function (length) {
		length = length || this.exports.generate.integer(5,10);
		var word = '';
		for (var i = 0; i < length; ++i) {
			word += this.exports.helpers.getRandomItem(values['letters']);
		}
		return word;
	}
1185112
function readNumericString(s, minValue) {
    var length = readLength(s);
    length = (length + minValue + 1) / 2;
    s.readPadding(length);
}
1130757
function padNumber(number, length)
    {
        var result = number.toString();

        while (result.length < length)
            result = '0' + result;

        return result;
    }
910054
static function generate($length = 10)
    {
        $chars = "A1B2C3D4E5F6G7H8I9J0K1L2M3N4O5P6Q7R8S9T0U1V2W3X4Y5Z6a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6";
        $key = "";

        for ($i = 0; $i < $length; $i++) {
            $key .= $chars{mt_rand(0, strlen($chars) - 1)};
        }

        return $key;
    }
1225139
def generate(length):
    """"""
    if not isinstance(length, int) or length < 2:
        raise TypeError('length must be a positive integer greater than 1.')

    # first digit cannot be 0
    digits = [random.randint(1, 9)]

    for i in range(length-2):
        digits.append(random.randint(0, 9))
    digits.append(get_check_digit(''.join(map(str, digits))))

    return ''.join(map(str, digits))
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))
    })
  })
}