超级简单的随机字符串生成器-用于密码

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了超级简单的随机字符串生成器-用于密码相关的知识,希望对你有一定的参考价值。

I needed a way to generate some random strings for passwords, a number of methods seemed a little over the top so below is my simplified version that does the trick. I have set it to use non-confusing characters, so no i's, l's, 0's but very easy to change.
  1. <?php
  2.  
  3. /*
  4. * str_shuffle to generate a random series of characters based on those provided, uniqid added, then shuffled again.
  5. * substr will trim the output down to between 10 and 12 characters randomly.
  6. */
  7.  
  8. //Generate 10 Random Strings
  9. $i = 1;
  10. while($i <= 10){
  11. echo substr(str_shuffle(uniqid(str_shuffle("abcdefghjkmnpqrstwxyzABCDEFGHJKMNPQRSTWXYZ23456789"))), 0, rand(10,12))."<br/>";
  12. $i++;
  13. }
  14.  
  15. ?>

以上是关于超级简单的随机字符串生成器-用于密码的主要内容,如果未能解决你的问题,请参考以下文章

随机密码生成器 Swift 3?

php生成随机密码(php自定义函数)转自先锋教程网

php随机密码函数的实例代码

python快速生成验证码(密码)

21个常用代码片段

mkpasswd密码随机生成器