PHP generated random password (PHP custom function) from the Pioneer tutorial network

Source: Internet
Author: User

PHP generates random passwords (PHP custom functions)
time: 2015-12-16-20:43:49 Source: Network
Introduction: PHP Random password generation code, using PHP custom function to generate a specified length of random password, password rules for lowercase letters and numbers of random strings, the length can be customized.

Generates a random password function that generates a random string with a password of lowercase letters and numbers, which can be customized in length.

Copy CodeThe code is as follows: <?php
/*
* PHP automatically generate new password custom function (with example demo)
Applicable environment: Php5.2.x/mysql 5.0.x
Code Xujiajay
Contact information: [Email protected]
* */
function Genpassword ($min = 5, $max = 8)
{
$validchars = "abcdefghijklmnopqrstuvwxyz123456789";
$max _char=strlen ($validchars)-1;
$length =mt_rand ($min, $max);
$password = "";
for ($i =0; $i < $length; $i + +)
{
$password. = $validchars [Mt_rand (0, $max _char)];
}
return $password;
}
echo "New password:". Genpassword (). " <br> ";
echo "New password:". Genpassword (5,10). " <br> ";
?> related articles
    • Php method for generating six-digit random passwords
    • PHP generates a random user name and password method, custom password character set
    • A simple way to generate random passwords in PHP
    • PHP generates a custom function for random user names and passwords
    • PHP generates random password functions, php password generator
    • PHP Random Password Function Introduction example
    • Two ways to generate strong passwords in PHP
    • Example of a function that generates random passwords in PHP

PHP generated random password (PHP custom function) from the Pioneer tutorial network

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.