/**
* 生成永遠唯一的密鑰碼
* sha512(返回128位) sha384(返回96位) sha256(返回64位) md5(返回32位)
* 還有很多Hash函數......
* @author xiaochaun
* @param int $type 返回格式:0大小寫混合 1全大寫 2全小寫
* @param string $func 啓用算法:
* @return string
*/
function createSecret($type=0, $func='md5')
{
$uid = md5(uniqid(rand(),true).microtime());
$hash = hash($func, $uid);
$arr = str_split($hash);
foreach($arr as $v){
if($type==0){
$newArr[]= empty(rand(0,1)) ? strtoupper($v) : $v;
}
if($type==1){
$newArr[]= strtoupper($v);
}
if($type==2){
$newArr[]= $v;
}
}
return implode('', $newArr);
}