A simple way to create a random password in PHP
$password = substr(md5(time()), 0, rand(4,8));
Byte sized tech know-how.
A simple way to create a random password in PHP
$password = substr(md5(time()), 0, rand(4,8));
Copyright © 2024 Txt
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]