Wednesday, November 25, 2015

Auto password Generator in PHP

As a developer sometime we have to put auto password generation in our registration to help user to get a strong password and their convenience. In PHP, it's very simple to create a auto password generator. PHP has two build in functions one is SUBSTR and another one is STR_SHUFFLE.

Subastr function can slice an specific length of characters from a given string, the function is

string substr ( string $string , int $start [, int $length ] )
The first parameter is the given string, second one is the starting point of substring and last one is for total length of sub string.You can see details in PHP manual


Another function str_shuffle is  Randomly shuffles a string
string str_shuffle ( string $str )
It only have one parameter which is given string. You also can learn more about from http://php.net/manual/en/function.str-shuffle.php.

so here is simple you can use for auto password generation.

<?php
$string="hfjksdhkfjs;lkc;lkelkr;glk9320930255454";
$generation="substr(str_shuffle($string),0,10);
echo $generation;
?>

I have created a tutorial in my youtube channel about auto password generation in PHP. if you want you can take a look. 









3 comments:

  1. Hard Rock Casino Resort Lake Tahoe - MapyRO
    The Hard Rock Hotel & Casino Lake Tahoe is a AAA 경상남도 출장샵 Four Diamond Rated AAA Four 구리 출장샵 Diamond rated hotel and casino located 문경 출장샵 in Stateline, 고양 출장샵 Nevada. 경산 출장샵

    ReplyDelete