· 5 years ago · Aug 06, 2020, 07:38 PM
1function getSignature($system_id, $version, array $args, $system_key){
2 $md5=array();
3 $md5[]=$system_id;
4 $md5[]=$version;
5 foreach($args as $d_arg){
6 $arg=$d_arg;
7 if(is_array($arg)){
8 if(count($arg)){
9 $recursive_arg='';
10 array_walk_recursive($arg,function($item)use(&$recursive_arg){if(!is_array($item)){$recursive_arg.=($item.':');}});
11 $md5[]=substr($recursive_arg,0,strlen($recursive_arg)-1);}
12 else{$md5[]='';}}
13 else{$md5[]=$arg;}
14 };
15 $md5[]=$system_key;
16 $md5_str=implode('*',$md5);
17 $md5=md5($md5_str);
18 echo $md5_str;
19
20 echo "\n";
21
22 return $md5;
23}
24
25$signature = getSignature(1725, 1, array(), 'secret_key');
26echo $signature;