生成自定义随机字符串的方法

看代码:

function generate_custom_key($length = 8 ) {
	$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_ []{}<>~`+=,.;:/?|';
	$charslen = strlen($chars);
	$str = '';
	for($i = 0; $i < $length; $i++ ) {
		$str .= $chars[mt_rand(0, $charslen - 1)];
	}
	return $str;
}

绝对随机,绝对难破解,有没有发现?

18
Sep 2012
AUTHOR WiFeng
CATEGORY Web
COMMENTS 1 Comment

仅有一条评论 »

  1. Nicol Nicol

    What a neat article. I had no inknlig.

添加新评论 »

   点击刷新验证码