PHP generates random cipher functions

Source: Internet
Author: User

Name: Random_password ()
#
# Author: Chrishent, Jeremyasklaft
#
# Date: May 1999, October 2000
#
# use: Returns a random word used as a password. Vowels and consonants
# is alternating to a (hope) pronouncable, so
# an unforgettable result.
#
# usage: $ my_new_password = Random_password ();
#
# (c) 1999 Chrishent. Grant permission is free to include this script
# your program. Provide this head is intact.
#
#2000 year October-Jasmine acid-Perl code porting to PHP

function Random_password () {

$maxlen = 6; # Default to 6

# Build tables of vowels & consonants. Single vowels are repeated so
# resultant words are not dominated by dipthongs

$vowel = Array ("A", "E", "I", "O", "U", "Y", "AI", "au", "ay", "EA", "ee", "EU", "ia", "ie", "io", "OA", "Oi", "oo", "oy") ;
$consonant = Array ("B", "C", "D", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Qu", "R", "s", "T", "V", "w", "X", "Z", " Th "," st "," sh "," ph "," ng "," nd ");
$password = "";

Srand (Double) microtime () *1000000);
$vowelnext = (int) rand (0,1); # initialise to 0 or 1 (ie true or false)

do {
if ($vowelnext) {
$password = $password. $vowel [Rand (0,sizeof ($vowel))];
} else {
$password = $password. $consonant [Rand (0,sizeof ($consonant))];
}

$vowelnext =! $vowelnext; # Swap Letter type for the next one

while (strlen ($password) < $maxlen);

return $password;

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.