How to generate random password with PHP?

后端 未结 19 2225
栀梦
栀梦 2020-12-01 00:45

Or is there a software to auto generate random passwords?

19条回答
  •  悲&欢浪女
    2020-12-01 01:26

    I want to play the game. The simplest way would be to do:

    function rand_passwd( $length = 8, $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' ) {
        return substr( str_shuffle( $chars ), 0, $length );
    }
    

    This is pretty much just a modification of the first answer. Specify the characters you want in the second parameters and the length of the password in the first.

提交回复
热议问题