Posted in PHP Random Password in PHP Binny V A October 20, 2008 4 Comments on Random Password in PHP A simple way to create a random password in PHP $password = substr(md5(time()), 0, rand(4,8)); Author: Binny V AA philosopher programmer who specializes in backend development and stoicism.
4 thoughts on “Random Password in PHP”
thankz for the code 😀
If I remove rand(4,8) or if I put rand (4,4) then it is generating unique password every second… can we over come it? (may be using something else instead of time() )
Try using microtime(). And you can just use 4 instead of rand(4,4). I used that to change the length of password randomly.
Thankz Binny.. thatz working 😀
Nice snipped – but it is insecure as it will produce passwords only containing [a-f0-9]