博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
腾讯app任务集市签名 php实现代码
阅读量:6910 次
发布时间:2019-06-27

本文共 2042 字,大约阅读时间需要 6 分钟。

1 
$val){14   if($key != "sig"){15     $array_str = str_split($val);16     foreach($array_str as $key2=>$val2){17       if(!ereg("^([a-zA-Z0-9!*()])",$val2)){18         $array_str[$key2] = "%".strtoupper(bin2hex($val2));19       }20      }21     $val = implode('',$array_str);22     if($str == ""){23       $str = $key."=".$val;24     }else{25     $str = $str."&".$key."=".$val;26     }27   }28 }29 $str = urlencode($str);30 $sig2 = base64_encode(custom_hmac('sha1', $paths.$str, $appKey));31 32 33 if($sig2 == $_GET['sig'] && $md5Str == $md5pkey){34 //验证通过35    if($step == 1){36 //处理代码37 $data = array("ret"=>0,"msg"=>"OK","zoneid"=>"1");38 echo mjson($data);39    }elseif($step == 2){40 //处理代码 41 $data = array("ret"=>0,"msg"=>"OK2","zoneid"=>"1");42 echo mjson($data);43   }elseif($step == 3){44 //处理代码 45 $data = array("ret"=>0,"msg"=>"OK3","zoneid"=>"1");46 echo mjson($data);47    }48 }else{49 //验证不通过50 $data = array("ret"=>200,"msg"=>'参数错误',"zoneid"=>"1");51 echo mjson($data);52 }53 54 function mjson($data)55 {56 if (!headers_sent()) header("Content-Type: application/json; charset=utf-8");57 echo json_encode($data);58 } 59 function custom_hmac($algo, $data, $key, $raw_output = true)60 {61 $key = $key."&";62 $algo = strtolower($algo);63 $pack = 'H'.strlen($algo('test'));64 $size = 64;65 $opad = str_repeat(chr(0x5C), $size);66 $ipad = str_repeat(chr(0x36), $size);67 68 if (strlen($key) > $size) {69 $key = str_pad(pack($pack, $algo($key)), $size, chr(0x00));70 } else {71 $key = str_pad($key, $size, chr(0x00));72 }73 74 for ($i = 0; $i < strlen($key) - 1; $i++) {75 $opad[$i] = $opad[$i] ^ $key[$i];76 $ipad[$i] = $ipad[$i] ^ $key[$i];77 }78 79 $output = $algo($opad.pack($pack, $algo($ipad.$data)));80 81 return ($raw_output) ? pack($pack, $output) : $output;82 } 83 ?>

 

转载于:https://www.cnblogs.com/xiaojingjing/p/3791569.html

你可能感兴趣的文章
hive复杂类型与java类型的对应
查看>>
[Ubuntu] ubuntu10.04系统维护之Wine的安装
查看>>
iOS获取UIView上某点的颜色值
查看>>
cocos2d-x 3.0 android mk文件 之 自己主动遍历*.cpp文件
查看>>
python数字图像处理(7):图像的形变与缩放
查看>>
设计模式-观察者模式(上)<转>
查看>>
RabbitMQ 集群与高可用配置
查看>>
Android IOS WebRTC 音视频开发总结(六二)-- 大数据解密国外实时通讯行业开发现状...
查看>>
openvas
查看>>
消息推送技术
查看>>
flume 自己定义 hbase sink 类
查看>>
组织目标与个人目标
查看>>
Educational Codeforces Round 8 E. Zbazi in Zeydabad 树状数组
查看>>
自己主动下载源代码_并编译_打包_部署_重新启动服务的Shell脚本
查看>>
常思己过 如切如磋
查看>>
Android中使用Handler造成内存泄露的分析和解决
查看>>
《ArcGIS Engine+C#实例开发教程》第六讲 右键菜单添加与实现
查看>>
ArrayList与LinkedList区别
查看>>
Linux 学习之路:认识shell和bash
查看>>
POJ 3041(最小点覆盖)
查看>>