将 md5 更新为 sha512 authorizenet
Updating md5 to sha512 authorizenet
我正在将 DPM authorizenet 的 md5 更新为 sha512-
请帮帮我 -
我无法正常工作。
查看代码更改 -
正在为 x_hp_hash -
生成指纹
来自 md5 -
if (function_exists('hash_hmac')) {
return hash_hmac("md5", $api_login_id . "^" . $fp_sequence . "^" .
$fp_timestamp . "^" . $amount . "^", $transaction_key);
}
return bin2hex(mhash(MHASH_MD5, $api_login_id . "^" . $fp_sequence . "^" . $fp_timestamp . "^" . $amount . "^", $transaction_key));
到 sha512 -
$signature_key = hex2bin($signature_key);
if (function_exists('hash_hmac')) {
return hash_hmac("sha512", $api_login_id . "^" . $fp_sequence . "^" .
$fp_timestamp . "^" . $amount . "^", $signature_key);
}
return bin2hex(mhash(MHASH_SHA512, $api_login_id . "^" . $fp_sequence . "^" . $fp_timestamp . "^" . $amount . "^", $signature_key));
在获取响应并比较 x_sha_hash 值时
来自 md5 -
if(strtoupper(md5($this->md5_setting . $this->api_login_id . $this
->transaction_id . $amount)) == $this->md5_hash){
//valid
} else{
//not valid
}
更改为 sha512 -
$this->signature_key = hex2bin($this->signature_key);
$string = '^'.$this->api_login_id.'^'.$this->transaction_id.'^'.$amount.'^';
if(strtoupper(HASH_HMAC('sha512', $string, $this->signature_key)) == $this->SHA2_Hash){
//valid
} else{
//not valid
}
我做错了什么?
在我这边验证交易时,它说请检查您的 md5 设置。它根据代码段中显示的最后一个代码进行验证。
我的签名密钥=E284BDC12A45A7F5B0933A352EB1C3F25E91A3B92360693D94E4366190EF12E78F6CFE8601751F719DA7A72ABBA117BF0161F8A1DD894DADE3C56A8AD5=8135=
x_hp_hash 使用第二个代码片段提交(即 sha512 指纹)
x_hp_hash = b4c9e1878f88aa9c4f808761ed8ceee71ab117cc0f1297b2d850e28351f08fc52bd528a7538c832568c674a1d5095ead1a5383a626c9797587ab16bae7=e145f]
提交后收到回复 -
X_SHA2_Hash - 19AB7947709CF6CB2B8415784EBD7669FCDE5D83B69EC8C716203806A3235308187668F5783F9CA0F1AE8A47808EDAB241025A8AF61A2FABC27FA6AAAEA18FFD8
生成的哈希码 -
3E6427E67271B1F0732D3D95217D25EE4D7C4103C906A6CB70943498698157F48F7BECD5C7E5393CF2A489B464070A7778F15757385E8F29029CFC3F66256F]5[=]
使用上面的最后一个片段。
所以它们不相等,所以不是有效交易。
我成功了
而不是仅使用以下三个字段
$api_login_id
$transaction_id
$amount;
我不得不使用以下所有字段,请参阅 -
$hashData = implode('^', [
$_POST['x_trans_id'],
$_POST['x_test_request'],
$_POST['x_response_code'],
$_POST['x_auth_code'],
$_POST['x_cvv2_resp_code'],
$_POST['x_cavv_response'],
$_POST['x_avs_code'],
$_POST['x_method'],
$_POST['x_account_number'],
$_POST['x_amount'],
$_POST['x_company'],
$_POST['x_first_name'],
$_POST['x_last_name'],
$_POST['x_address'],
$_POST['x_city'],
$_POST['x_state'],
$_POST['x_zip'],
$_POST['x_country'],
$_POST['x_phone'],
$_POST['x_fax'],
$_POST['x_email'],
$_POST['x_ship_to_company'],
$_POST['x_ship_to_first_name'],
$_POST['x_ship_to_last_name'],
$_POST['x_ship_to_address'],
$_POST['x_ship_to_city'],
$_POST['x_ship_to_state'],
$_POST['x_ship_to_zip'],
$_POST['x_ship_to_country'],
$_POST['x_invoice_num'],
]);
$hash = hash_hmac('sha512', '^'.$hashData.'^', hex2bin($signatureKey));
$hash = strtoupper($hash);
if($this->SHA2_Hash === $hash) {
//valid
}
因此使用 authorize.net 中的所有 x_fields 生成哈希码
我正在将 DPM authorizenet 的 md5 更新为 sha512- 请帮帮我 -
我无法正常工作。
查看代码更改 -
正在为 x_hp_hash -
生成指纹来自 md5 -
if (function_exists('hash_hmac')) {
return hash_hmac("md5", $api_login_id . "^" . $fp_sequence . "^" .
$fp_timestamp . "^" . $amount . "^", $transaction_key);
}
return bin2hex(mhash(MHASH_MD5, $api_login_id . "^" . $fp_sequence . "^" . $fp_timestamp . "^" . $amount . "^", $transaction_key));
到 sha512 -
$signature_key = hex2bin($signature_key);
if (function_exists('hash_hmac')) {
return hash_hmac("sha512", $api_login_id . "^" . $fp_sequence . "^" .
$fp_timestamp . "^" . $amount . "^", $signature_key);
}
return bin2hex(mhash(MHASH_SHA512, $api_login_id . "^" . $fp_sequence . "^" . $fp_timestamp . "^" . $amount . "^", $signature_key));
在获取响应并比较 x_sha_hash 值时 来自 md5 -
if(strtoupper(md5($this->md5_setting . $this->api_login_id . $this
->transaction_id . $amount)) == $this->md5_hash){
//valid
} else{
//not valid
}
更改为 sha512 -
$this->signature_key = hex2bin($this->signature_key);
$string = '^'.$this->api_login_id.'^'.$this->transaction_id.'^'.$amount.'^';
if(strtoupper(HASH_HMAC('sha512', $string, $this->signature_key)) == $this->SHA2_Hash){
//valid
} else{
//not valid
}
我做错了什么? 在我这边验证交易时,它说请检查您的 md5 设置。它根据代码段中显示的最后一个代码进行验证。
我的签名密钥=E284BDC12A45A7F5B0933A352EB1C3F25E91A3B92360693D94E4366190EF12E78F6CFE8601751F719DA7A72ABBA117BF0161F8A1DD894DADE3C56A8AD5=8135=
x_hp_hash 使用第二个代码片段提交(即 sha512 指纹) x_hp_hash = b4c9e1878f88aa9c4f808761ed8ceee71ab117cc0f1297b2d850e28351f08fc52bd528a7538c832568c674a1d5095ead1a5383a626c9797587ab16bae7=e145f]
提交后收到回复 -
X_SHA2_Hash - 19AB7947709CF6CB2B8415784EBD7669FCDE5D83B69EC8C716203806A3235308187668F5783F9CA0F1AE8A47808EDAB241025A8AF61A2FABC27FA6AAAEA18FFD8
生成的哈希码 - 3E6427E67271B1F0732D3D95217D25EE4D7C4103C906A6CB70943498698157F48F7BECD5C7E5393CF2A489B464070A7778F15757385E8F29029CFC3F66256F]5[=]
使用上面的最后一个片段。
所以它们不相等,所以不是有效交易。
我成功了
而不是仅使用以下三个字段
$api_login_id
$transaction_id
$amount;
我不得不使用以下所有字段,请参阅 -
$hashData = implode('^', [
$_POST['x_trans_id'],
$_POST['x_test_request'],
$_POST['x_response_code'],
$_POST['x_auth_code'],
$_POST['x_cvv2_resp_code'],
$_POST['x_cavv_response'],
$_POST['x_avs_code'],
$_POST['x_method'],
$_POST['x_account_number'],
$_POST['x_amount'],
$_POST['x_company'],
$_POST['x_first_name'],
$_POST['x_last_name'],
$_POST['x_address'],
$_POST['x_city'],
$_POST['x_state'],
$_POST['x_zip'],
$_POST['x_country'],
$_POST['x_phone'],
$_POST['x_fax'],
$_POST['x_email'],
$_POST['x_ship_to_company'],
$_POST['x_ship_to_first_name'],
$_POST['x_ship_to_last_name'],
$_POST['x_ship_to_address'],
$_POST['x_ship_to_city'],
$_POST['x_ship_to_state'],
$_POST['x_ship_to_zip'],
$_POST['x_ship_to_country'],
$_POST['x_invoice_num'],
]);
$hash = hash_hmac('sha512', '^'.$hashData.'^', hex2bin($signatureKey));
$hash = strtoupper($hash);
if($this->SHA2_Hash === $hash) {
//valid
}
因此使用 authorize.net 中的所有 x_fields 生成哈希码