PHP/MySQL - Best way to create unique random string?

后端 未结 10 2120
囚心锁ツ
囚心锁ツ 2020-12-15 04:20

How do I create a random unique string in MySQL?

when I need to create a random string in PHP I use this function:

public function generateString($le         


        
10条回答
  •  -上瘾入骨i
    2020-12-15 04:57

    If you want to use these strings for security purpose, you should use openssl_random_pseudo_bytes which will indicate you if PHP was able to use a strong algorithm to generate it:

    Ouput needs some cleaning though. Have a look at this question for more info.

提交回复
热议问题