标签:create control names function tor sub yii date each
<?php
/**
* Created by PhpStorm.
* User: Shinelon
* Date: 2019/3/22
* Time: 21:18
*/
namespace frontend\controllers;
use yii\rest\ActiveController;
class SignController extends ActiveController
{
public $modelClass=‘‘;
public function actionGetSign(){
$secret=‘1609phpB‘;
//接值
$username=\Yii::$app->request->post(‘username‘);
$password=\Yii::$app->request->post(‘password‘);
$rand=rand(11111,99999);
$time=time();
//拼到数组里
$arr=[
‘username‘=>$username,
‘password‘=>$password,
‘rand‘=>$rand,
‘time‘=>$time
];
//进行排序
ksort($arr);
$str=‘‘;
foreach ($arr as $k=>$v){
$str .="$k=$v&";
}
$last_str=substr($str,0,-1);
//进行md5加密
$md_str=md5($last_str);
$sign=md5($md_str.$secret);
return $sign;
}
}
标签:create control names function tor sub yii date each
原文地址:https://www.cnblogs.com/findher/p/10626350.html