PayUMoney C# API 中请求和响应中的哈希计算
哈希序列 =
键|txnid|数量|产品信息|名字|电子邮件|udf1|udf2|udf3|udf4|udf5||||||盐;
$hash = hash("sha512", $hashSequence);
PayUMoney 仪表板上提供盐的位置。
注意:计算 hashSequence 时要使用空白的 udf 字段,即使商家在输入请求中没有传递任何 udf 字段。
对于响应哈希,与支付请求哈希相比,变量的顺序是相反的。此外,在 salt 和 udf1 之间添加了一个状态变量
顺序
hashSequence = salt|status||||||udf5|udf4|udf3|udf2|udf1|email|firstname|productinfo|amount|txnid|key;
$hash = hash("sha512", $hashSequence);
PayUMoney 仪表板上提供盐的位置。
这是响应哈希计算的示例代码:-
bool isCheckSum = false;
var strhash = Request.Form["hash"];
var strstatus = Request.Form["status"];
var strfirstname = Request.Form["firstname"];
var stramount = Request.Form["amount"];
var strtxnid = Request.Form["txnid"];
var strkey = Request.Form["key"];
var strproductinfo = Request.Form["productinfo"];
var stremail = Request.Form["email"];
var stradditionalCharges = Request.Form["additionalCharges"];
string strudf1 = Request.Form["udf1"];
string strudf2 = Request.Form["udf2"];
string strudf3 = Request.Form["udf3"];
string strudf4 = Request.Form["udf4"];
string strudf5 = Request.Form["udf5"];
System.Security.Cryptography.SHA512Managed sha512 = new System.Security.Cryptography.SHA512Managed();
byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(strSALT + "|" + strstatus + "||||||" + strudf5 + "|" + strudf4 + "|" + strudf3 + "|" + strudf2 + "|" + strudf1 + "|" + stremail + "|" + strfirstname + "|" + strproductinfo + "|" + stramount + "|" + strtxnid + "|" + strkey);
byte[] hashBytes = sha512.ComputeHash(inputBytes);
byte[] hashValue;
string hex = "";
hashValue = sha512.ComputeHash(inputBytes);
foreach (byte x in hashValue)
{
hex += String.Format("{0:x2}", x);
}
if(strhash == hex)
{
isCheckSum = true;
}