public static function random($length) {
    if ($length <= 0) return '';
    $str = '';
    for ($i = 0; $i < $length; $i++) {
      $rand = rand(0, 35);
      if ($rand >= 10)
        $str .= chr(ord('a') + $rand-10); // a - z
      else
        $str .= chr(ord('0') + $rand);    // 0 - 9
    }
    
    return $str;
  }