To the Top

Random Password/String Generator

Buy Me A Coffee

This page calls the API to generate a random string for password purposes.

API (Application Programming Interface)

Please contact for details - as this API is being DDOS-ed in the past and I cannot afford this.

The API may return JSON-encoded data (random):
"KeUkcwjdBIrmgEzvKOlRuNKowAfgngeyLyjnuSRwaIjHNiDXxoprBzgyALfnsKmDIVqDnHAOQjVeRZBOOqGQqmPqyueqEQtNlkRZrRnIBJmSjohxfnNVacMYXqOcHIpt"
Parameter n is the length of the output string. Parameter x specifies the mask, where bit 1 = upper case, bit 2 = lower case, bit 4 = digits and bit 8 = special characters.

Serverless API for Generating Random Data

The Random API is implemented as a CloudFlare Serverless Function which runs on the CloudFlare Edge Network Nodes. You may implement one and host it on cloudflare's Free-Tier worker plan (10M per day).

Complete API Source Code (PHP)

  function generateRandomString($length, $bitmask) {
      $uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
      $lowercase = 'abcdefghijklmnopqrstuvwxyz';
      $numbers = '0123456789';
      $special  = '~!@#$%^&*(){}[],./?';   
      $characters = '';
      if ($bitmask & 1) {
        $characters .= $uppercase;
      }      
      if ($bitmask & 2) {
        $characters .= $lowercase;
      }
      if ($bitmask & 4) {
        $characters .= $numbers;
      }
      if ($bitmask & 8) {
        $characters .= $special;
      }
      if (!$characters) {
        $characters = $uppercase . $lowercase;
      }
      $charactersLength = strlen($characters);
      $randomString = '';
      for ($i = 0; $i < $length; $i++) {
          $randomString .= $characters[rand(0, $charactersLength - 1)];
      }
      return $randomString;
  }  
  $x = 0;
  if (isset($_GET['x'])) {
    $x = (integer)$_GET['x'];
  }
  $n = 32;
  if (isset($_GET['n'])) {
    $n = (integer)$_GET['n'];
    if ($n < 1) {
      $n = 32;
    }
  }

  $data = generateRandomString($n, $x);
  header("Access-Control-Allow-Origin: *");  
  header('Content-Type: application/json');
  die(json_encode($data));  

Share: List of Many Other Online Tools