Jquery中文网 www.jquerycn.cn
Jquery中文网 >  脚本编程  >  php  >  正文 php生成强密码的程序

php生成强密码的程序

发布时间:2015-08-14   编辑:www.jquerycn.cn
本文为大家提供用php生成强密码的两种方法。方法一使用时间戳与随机数的方法,生成强密码。方法二,原理大致相同,但生成的密码复杂度更强。

本文为大家提供用php生成强密码的两种方法。
方法一使用时间戳与随机数的方法,生成强密码。
方法二,原理大致相同,但生成的密码复杂度更强。

有需要的朋友,可以参考下。
 

复制代码 代码示例:

<?php
/**
  php生成强密码
  linK:www.jquerycn.cn 2013/3/2
*/
$password_length = 9;

function make_seed() {
list($usec, $sec) = explode(’ ‘, microtime());
return (float) $sec + ((float) $usec * 100000);
}

srand(make_seed());

$alfa = “1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM”;
$token = “”;
for($i = 0; $i < $password_length; $i ++) {
$token .= $alfa[rand(0, strlen($alfa))];
}
echo $token;

//方法2
// Create Password
$totalChar = 8; // number of chars in the password
$salt = “abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ123456789″; // salt to select chars from
srand((double)microtime()*1000000); // start the random generator
$Spass=””; // set the inital variable
for ($i=0;$i<$totalChar;$i++) // loop and create password
$Spass = $Spass . substr ($salt, rand() % strlen($salt), 1);

您可能感兴趣的文章:
php生成强密码的程序
php生成随机产生六位数密码的代码
有关discuz程序中PHP加密函数的原理分析
php 生成指定长度与强度的密码
PHP最强大的随机字符串生成函数
php随机生成4位数字验证码
PHP中常用的加密解密方法总结
mcrypt如何加/解密?
php生成随机数的例子
PHP 加密:Password Hashing API

关键词: php随机数  随机数   
[关闭]