超级简单的随机字符串生成器-用于密码
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.
<?php /* * str_shuffle to generate a random series of characters based on those provided, uniqid added, then shuffled again. * substr will trim the output down to between 10 and 12 characters randomly. */ //Generate 10 Random Strings $i = 1; while($i <= 10){ echo substr(str_shuffle(uniqid(str_shuffle("abcdefghjkmnpqrstwxyzABCDEFGHJKMNPQRSTWXYZ23456789"))), 0, rand(10,12))."<br/>"; $i++; } ?>
以上是关于超级简单的随机字符串生成器-用于密码的主要内容,如果未能解决你的问题,请参考以下文章