Generate random passwords in php only

Source: Internet
Author: User
This article describes how to generate 12-bit random passwords in php only, which is safe and reliable. if you are interested, you can refer to php to generate a random password, which is convenient and quick, A secure and reliable password can be generated randomly.

The sharing code is as follows:

<? Phpheader ("Content-type: text/html; charset = utf-8"); function getRandPass ($ length = 6) {$ password = ''; // add the desired character to the following string. the default value is 0-9 and 26 English letters $ chars = "0123456789 characters"; $ char_len = strlen ($ chars ); for ($ I = 0; $ I <$ length; $ I ++) {$ loop = mt_rand (0, ($ char_len-1 )); // use this string as an array, randomly retrieve a character, and concatenate it into the number of digits you need $ password. = $ chars [$ loop];} return $ password;} echo getRandPa Ss (12); // Generate a random 12-digit password?>

I hope this article will be helpful for you to learn about php programming. you can try to change the number of generated passwords.

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.