Home > php教程 > php手册 > PHP 签名

PHP 签名

WBOY
Release: 2016-06-06 19:58:39
Original
1048 people have browsed it

首先定义一个数组用于存储签名所需的各个参数 , 并用 ksort 方法对其进行键名的升序排序 $array [ 'access_token' ]= $accesstoken ; $array [ 'app_id' ]= $appid ; $array [ 'timestamp' ]=date( 'Y-m-jG:i:s' ); ksort( $array ); 将数组传入 buildPlainT

首先定义一个数组用于存储签名所需的各个参数,并用ksort方法对其进行键名的升序排序

$array['access_token']=$accesstoken;

$array['app_id']=$appid;

$array['timestamp']=date('Y-m-jG:i:s');

ksort($array);


将数组传入buildPlainText方法生成明文

$plaintext= buildPlainText($array);


将明文加密成为接口中所需的入参sign$appsecret为应用密钥

$cipherText= base64_encode(hash_hmac("sha1",$plaintext,$appsecret,$raw_output=True));

$cipherText= urlencode($cipherText);


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template