随机密码生成器PHP类
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了随机密码生成器PHP类相关的知识,希望对你有一定的参考价值。
I rewrote [this snippet](http://snipplr.com/view/15402/php-password-generator/).Usage:
$password1 = new Password;
$password2 = new Password;
echo '<p>' . $password1->generate() . '</p>';
echo '<p>' . $password2->generate(array('length' => 50)) . '</p>';
<?php /** * Generate a random password */ class Password { /** * Generate the new password * * @access public * @param array $params * @return string **/ { $upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; $lower = "abcdefghijklmnopqrstuvwxyz"; $number = "0123456789"; $seed_length = 0; $seed = ''; if($use_upper === TRUE){ $seed_length += 26; $seed .= $upper; } if($use_lower === TRUE){ $seed_length += 26; $seed .= $lower; } if($use_number === TRUE){ $seed_length += 10; $seed .= $number; } $seed .= $use_custom; } for($i = 1; $i <= $length; $i++){ } return $password; } // End of generate } // End of Class Password ?>
以上是关于随机密码生成器PHP类的主要内容,如果未能解决你的问题,请参考以下文章