function getRandomPasswd($passLen) { if ($passLen > 0) { // echo 'Generating password ' . $passLen . '...' . PHP_EOL; } $wordsList = dirname(__FILE__) . '/linux.words.txt'; $aW1 = file($wordsList); $cn1 = count($aW1); if (is_array($aW1) && $cn1) { // echo 'Read ' . $cn1 . ' words from dictionary: ' . $wordsList . PHP_EOL; $pass = ''; while (strlen($pass) < $passLen) { $r1 = getRandomArrayValue($aW1); // Fill In Password With Dictionary Words While It Is Not Long Enough $pass .= trim(ucfirst($r1)); if (strlen($pass) > $passLen) { $pass = substr($pass, 0, $passLen); } } // // [ add random character password hardening #1 $r2 = rand(1, $passLen); $pass1 = substr($pass, 0, $r2); $pass1 .= getRandomChar(); $pass1 .= substr($pass, $r2 + 1, $passLen); // ] // // [ add random character password hardening #2 $fR2 = 0; $r3 = rand(1, $passLen); while (!$fR2) { if ($r3 == $r2) { $r3 = rand(1, $passLen); } else { $fR2 = 1; } } $pass2 = substr($pass1, 0, $r3); $pass2 .= getRandomChar(); $pass2 .= substr($pass1, $r3 + 1, $passLen); // ] // // [ add random character password hardening #3 $fR3 = 0; $r4 = rand(1, $passLen); while (!$fR3) { if ($r4 == $r3 || $r4 == $r2) { $r4 = rand(1, $passLen); } else { $fR3 = 1; } } $pass3 = substr($pass2, 0, $r4); $pass3 .= getRandomChar(); $pass3 .= substr($pass2, $r4 + 1, $passLen); // ] return $pass3; } return 'Error generating random password!' . PHP_EOL; }
$my_ssostatus = -2; //不存在该表项 } //以下是正常跳转流程 if ($my_ssostatus > 0) { //生成key:20位用户名,通过AES128密钥A加密得到64位16进制大写字母表 //$my_ssoname = $_SGLOBAL['supe_username']; $my_ssoname = $cur_name; /*if($value['tokentime'] != '0000-00-00 00:00:00'){ $my_ssoname = $cur_uid; }*/ /*if(preg_match('|(.*)_iHome$|',$my_ssoname)){ $my_ssoname = substr($my_ssoname,0,-6); }*/ $sso_name = "<@" . sprintf("%-20s", $my_ssoname) . "@>"; $sso_uid = "<@" . getRandomChar(10) . sprintf("%010u", $cur_uid) . "@>"; $key = M_encode($sso_name, aeskeyA); //用户名加密 $key1 = M_encode($sso_uid, aeskeyC); //UID加密 //重写URL,向BT请求Token $g_t_url = "http://" . BTURL . "buaasso.aspx?m=gettoken&key=" . $key . "&key1=" . $key1; $rc_i = 0; $rc_s = 0; while ($rc_i < 5) { if ($fp = fopen($g_t_url, "r")) { //无法连接打开文件,重连最多5次 $rc_s = 1; break; } $rc_i = $rc_i + 1;