PHP implementation randomly generate easy-to-remember passwords, PHP easy to remember passwords
The example in this paper describes the PHP implementation of random generation of easy-to-remember passwords. Share to everyone for your reference. The implementation method is as follows:
Here, by pre-defined words, let PHP randomly choose from these words to combine the generated password
function random_readable_pwd ($length =10) {//the wordlist from which the password gets generated//(change them as you Like) $words = ' Dog,cat,sheep,sun,sky,red,ball,happy,ice, '; $words. = ' Green,blue,music,movies,radio,green,turbo, '; $words. = ' Mouse,computer,paper,water,fire,storm,chicken, '; $words. = ' Boot,freedom,white,nice,player,small,eyes, '; $words. = ' Path,kid,box,black,flower,ping,pong,smile, '; $words. = ' coffee,colors,rainbow,plus,king,tv,ring '; Split by ",": $words = Explode (', ', $words); if (count ($words) = = 0) {die (' Wordlist is empty! ');} Add words while password is smaller than the given length $pwd = '; while (strlen ($PWD) < $length) {$r = Mt_rand (0, Count ($words)-1); $pwd. = $words [$r]; }//Append a number at the end if length > 2 and//reduce the password size to $length $num = Mt_rand (1, 99); if ($length > 2) {$pwd = substr ($pwd, 0, $length-strlen ($num)). $num; } else {$pwd = substr ($pwd, 0, $length); } return $pwd;} Usage Example: random_readable_pwd (Ten) = returns something Like:pingwater6, RADIOHAP28, sunwhite84, happykid44, etc ...
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/1019450.html www.bkjia.com true http://www.bkjia.com/PHPjc/1019450.html techarticle PHP Implementation randomly generate easy-to-remember passwords, PHP easy to remember the password in this paper, the implementation of PHP to randomly generate easy-to-remember passwords. Share to everyone for your reference. Concrete Implementation Method ...