简体   繁体   English

php脚本从md5生成校验和

[英]php script to generate checksum from md5

In order to calculate the checksum i need following things. 为了计算校验和,我需要注意以下几点。 these parameters are concatenated in a constant (no spaces) string made up of the values of the following parameters in the exact order listed below: o Secret Key o Merchant id o Currency o Total amount o Item list (item_name_1, Item_amount_1, item_quantity_1 to item_name_N, Item_amount_N, item_quantity_N) o Timestamp 这些参数以由以下参数的值组成的常数(无空格)字符串连接,该字符串按以下列出的确切顺序组成:o密钥o商户ID o货币o总金额o项目列表(item_name_1,Item_amount_1,item_quantity_1至item_name_N ,item_amount_N,item_quantity_N)o时间戳记

eg In that case the string befor hash will be: pLAZdfhdfdNh57583USD69.99Tier2 item69.9912010-06-14.14:34:33 例如,在这种情况下,字符串befor hash将为:pLAZdfhdfdNh57583USD69.99Tier2 item69.9912010-06-14.14:34:33

And using the MD5 hash function the result is: ghvsaf764t3w784tbjkegbjhdbgf 使用MD5哈希函数的结果是:ghvsaf764t3w784tbjkegbjhdbgf

i want to know how can i create a php script that will call md5 hash function with the inputs given above and based on that it will generate the hash function value that will be the checksum value for my coding.. 我想知道如何创建一个php脚本,该脚本将使用上面给定的输入调用md5哈希函数,并基于该脚本将生成哈希函数值,该值将是我的编码的校验和值。

try 尝试

echo md5('pLAZdfhdfdNh57583USD69.99Tier2 item69.9912010-06-14.14:34:33');

That will do exacly what you asked. 那完全可以满足您的要求。 Unless you need help writting the whole script. 除非您需要帮助编写整个脚本。

$md5String = $element1 . $element2 . $element3; // ..etc 
$myMd5 = md5($md5String);

I dont know how each of your items come into play but thats basically the easiest way to do it. 我不知道您的每个商品如何发挥作用,但这基本上是最简单的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM