一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

PHP生成隨機(jī)密碼類分享

類代碼:

<?php/** * php - Password Generator Class * Version 1.0.0 * */ if (@!is_object($passGen) || !isset($passGen)) {  $passGen = new Password;} class Password{   /**   * 大寫字母 A-Z   *   * @var array   */  protected $uppercase_chars;   /**   * 小寫字母 a-z   *   * @var array   */  protected $lowercase_chars;   /**   * 阿拉伯?dāng)?shù)字 0-9   *   * @var array   */  protected $number_chars;   /**   * 特殊字符   *   * @var array   */  protected $special_chars;   /**   * 其他特殊字符   *   * @var array   */  protected $extra_chars;   /**   * 最終用來生成密碼的所有字符   *   * @var array   */  protected $chars = array();   /**   * 密碼長度   *   * @var array   */  public $length;   /**   * 是否使用大寫字母   *   * @var boolean   */  public $uppercase;   /**   * 是否使用小寫字母   *   * @var boolean   */  public $lowercase;   /**   * 是否使用阿拉伯?dāng)?shù)字   *   * @var boolean   */  public $number;   /**   * 是否使用特殊字符   *   * @var boolean   */  public $special;   /**   * 是否使用額外的特殊字符   *   * @var boolean   */  public $extra;   /**   * 初始化密碼設(shè)置   *   * @param int $length   */  function Password($length = 12)  {    $this->length = $length;         $this->configure(true, true, true, false, false);  }   /**   * 配置   */  function configure($uppercase = false, $lowercase = false, $number = false,            $special = false, $extra = false  ) {    $this->chars = array();     $this->upper_chars  = array(                 "A", "B", "C", "D", "E", "F", "G", "H", "I",                 "J", "K", "L", "M", "N", "O", "P", "Q", "R",                 "S", "T", "U", "V", "W", "X", "Y", "Z"                );    $this->lower_chars  = array(                 "a", "b", "c", "d", "e", "f", "g", "h", "i",                 "j", "k", "l", "m", "n", "o", "p", "q", "r",                  "s", "t", "u", "v", "w", "x", "y", "z"                );    $this->number_chars = array(                 "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"                );    $this->special_chars = array(                 "!", "@", "#", "$", "%", "^", "&", "*", "(", ")"                );    $this->extra_chars  = array(                 "[", "]", "{", "}", "-", "_", "+", "=", "<",                 ">", "?", "/", "`", "~", "|", ",", ".", ";", ":"                );     if (($this->uppercase = $uppercase) === true) {      $this->chars = array_merge($this->chars, $this->upper_chars);    }    if (($this->lowercase = $lowercase) === true) {      $this->chars = array_merge($this->chars, $this->lower_chars);    }    if (($this->number = $number) === true) {      $this->chars = array_merge($this->chars, $this->number_chars);    }    if (($this->special = $special) === true) {      $this->chars = array_merge($this->chars, $this->special_chars);    }    if (($this->extra = $extra) === true) {      $this->chars = array_merge($this->chars, $this->extra_chars);    }     $this->chars = array_unique($this->chars);  }     /**   * 從字符列中生成隨機(jī)密碼   *   * @return string   **/  function generate()  {    if (empty($this->chars)) {      return false;    }     $hash    = '';    $totalChars = count($this->chars) - 1;         for ($i = 0; $i < $this->length; $i++) {      $hash .= $this->chars[$this->random(0, $totalChars)];    }     return $hash;  }   /**   * 生成隨機(jī)數(shù)字   *   * @return int   */  function random($min = 0, $max = 0)  {    $max_random = 4294967295;     $random = uniqid(microtime() . mt_rand(), true);    $random = sha1(md5($random));     $value = substr($random, 0, 8);    $value = abs(hexdec($value));     if ($max != 0) {      $value = $min + ($max - $min + 1) * $value / ($max_random + 1);    }     return abs(intval($value));  }}

調(diào)用:

<?php include_once 'password.class.php'; echo $passGen->generate(); //FS4yq74e2LeE

php技術(shù)PHP生成隨機(jī)密碼類分享,轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 久久精品视频一区二区三区 | 精品在线免费观看 | www.日本在线观看 | 在线精品视频免费观看 | 一区二区三区四区免费视频 | 伊人草草 | 色综合社区 | 韩国本免费一级毛片免费 | 亚洲人成网77777亚洲 | 男女毛片免费视频看 | 国产成人免费a在线资源 | 国产欧美精品区一区二区三区 | 成人污视频在线观看 | 国产社区 | 婷婷色九月综合激情丁香 | 亚洲综合影院 | 视频二区在线观看 | 五月深爱婷婷 | 香蕉97超级碰碰碰免费公 | 国产成人亚洲精品无广告 | 国产精品成人免费视频99 | 特级做a爰片毛片免费看一区 | 天天干免费视频 | 久久精品国产乱子伦多人 | 亚洲视色 | 激情文学亚洲 | 国产在视频线精品视频 | 中文字幕精品一区二区三区视频 | 玖玖精品视频在线 | 精品免费福利视频 | 综合网天天 | 亚洲国产一区二区三区最新 | 国产精品欧美激情在线播放 | 亚洲综合一区二区不卡 | 国产精品久久久久久久久鸭 | 综合色在线 | 在线观看www日本免费网站 | 国产91麻豆视频 | 99精品国产福利在线观看 | 久久精品中文字幕 | 亚洲伊人久久大香线蕉在观 |