Wednesday 6 January 2016

How to generate simple random password in php?

For Generating random password in php I am using two string function. First is str_shuffle function and second is substr function. str_shuffle function Randomly shuffle all characters of a string means it randomly rearrange string characters and substr function returns a part of a string. In sub string string function first parameter is string, second parameter is starting position of string and last parameter is length of string.

PHP Code
 echo substr(str_shuffle($string),0,12);  

1 comment:

  1. Have you read this yet? Don't use str_shuffle!