Summary of API permission design_PHP tutorial

WBOY
Release: 2016-07-14 10:09:22
Original
938 people have browsed it

Encryption method md5 (POST parameters (ascending order, except key sign parameters) + user key)

PHP encryption algorithm code:
[php]
foreach ($p as $v) {
$temp = explode("=", $v);
$pArr[$temp[0]] = $temp[1];
} }
ksort($pArr);
foreach ($pArr as $k => $v) {
$pStr2 .= $k . $v ;
} }
md5($pStr2 . $secret)
Note: When encrypting, you need to bring the timestamp to prevent client tampering.
Client, sort the parameters you need to pass in ascending order, and then add the key corresponding to your own key (the key is saved in the server database, and this cannot be disclosed to the outside world) to perform MD5 encryption, and pass the parameters sign is passed to the server.
After the server gets the sign value, it also sorts the parameters passed by the same algorithm, and obtains the key through the user's key query, and then performs an encryption algorithm to get the sign of the server and the one passed by the client. The signs are compared, and if they are the same, it means that they can be passed. If someone tampered with the data in the middle, the final encrypted sign will be inconsistent, which ensures the reliability and security of the data transmitted by the user.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477694.htmlTechArticleEncryption method md5 (POST parameters (ascending order, except key sign parameters) + user key) PHP encryption algorithm Code: [php] foreach ($p as $v) { $temp = explode(=, $v); $pArr[$temp[0]] =...
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!