Example of generating a random password in php

Source: Internet
Author: User
Welcome to the Linux community forum and interact with 2 million technical staff to enter the example of generating random passwords in php. This method is novel and different from the various methods circulating on the Internet to generate random passwords, you can specify the length and perform simple special settings. Example of generating random passwords in php for your reference. Sample Code :? Php ** auto-generated

Welcome to the Linux community forum and interact with 2 million technical staff> go to the php community to generate a random password example. This method is novel and different from the various methods circulating on the Internet to generate random passwords, you can specify the length and perform simple special settings. Example of generating random passwords in php for your reference. Sample Code :? Php/** auto-generated

Welcome to the Linux community forum and interact with 2 million technicians>

Example of generating a random password in php. This method is novel. Different from the various methods used to generate random passwords on the Internet, you can specify the length and perform simple special settings.

Example of generating random passwords in php for your reference.

Sample Code:

  

/**

Automatically generate Password

*/

Function password (length, special ){

Var iteration = 0;

Var password = "";

Var randomNumber;

If (special = undefined ){

Var special = false;

}

While (iteration <length ){

RandomNumber = (Math. floor (Math. random () * 100) % 94) + 33;

If (! Special ){

If (randomNumber >=33) & (randomNumber <= 47) {continue ;}

If (randomNumber >=58) & (randomNumber <= 64) {continue ;}

If (randomNumber >=91) & (randomNumber <= 96) {continue ;}

If (randomNumber >=123) & (randomNumber <= 126) {continue ;}

}

Iteration ++;

Password + = String. fromCharCode (randomNumber );

}

Return password;

}

?>

Usage:

Sample Code:

  

/**

Example of a random password call

*/

Password (8 );

// Outputs: Yrc7TxX3

Password (12, true );

// Outputs: C} 4_ege! P & # M

?>

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.