Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/240.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何发布sha512加密数据_Php_Post_Hash_Checksum_Sha512 - Fatal编程技术网

Php 如何发布sha512加密数据

Php 如何发布sha512加密数据,php,post,hash,checksum,sha512,Php,Post,Hash,Checksum,Sha512,我需要帮助我的PHP脚本。我需要以加密方式发布某些字段,如invoiceid、firstname、email等。校验和的公式是 sha512 (key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5||||||<SALT>) sha512(关键字| txnid |金额|产品信息|名字|电子邮件| udf1 | udf2 | udf3 | udf4 | udf5 | | | | | | 我需要通过s

我需要帮助我的PHP脚本。我需要以加密方式发布某些字段,如invoiceid、firstname、email等。校验和的公式是

sha512 (key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5||||||<SALT>)
sha512(关键字| txnid |金额|产品信息|名字|电子邮件| udf1 | udf2 | udf3 | udf4 | udf5 | | | | | |
我需要通过sha512发布上述变量。我不能这样做。请帮忙。我是一个学习者,我不擅长PHP

这是代码。我仍然得到校验和错误

<?php
function xxx_config() {

    $configarray = array(
     "FriendlyName" => array("Type" => "System", "Value"=>"XXX"),
     "alias" => array("FriendlyName" => "Merchant ID", "Type" => "text", "Size" => "20", ),
     "salt" => array("FriendlyName" => "SALT", "Type" => "text", "Size" => "20",),
     "mode" => array("FriendlyName" => "MODE", "Type" => "text", "Description" => "TEST or LIVE", ),

    );
    return $configarray;
}

function xxx_link($params) {


    # Gateway Specific Variables
    $key = $params['alias'];
    $gatewaymode = $params['mode'];
    $salt = $params['salt'];


    # Invoice Variables
    $txnid = $params['invoiceid'];
    $productinfo = $params["description"];
    $amount = $params['amount']; # Format: ##.##
    $currency = $params['currency']; # Currency Code

    # Client Variables
    $firstname = $params['clientdetails']['firstname'];
    $lastname = $params['clientdetails']['lastname'];
    $email = $params['clientdetails']['email'];
    $address1 = $params['clientdetails']['address1'];
    $address2 = $params['clientdetails']['address2'];
    $city = $params['clientdetails']['city'];
    $state = $params['clientdetails']['state'];
    $postcode = $params['clientdetails']['postcode'];
    $country = $params['clientdetails']['country'];
    $phone = $params['clientdetails']['phonenumber'];

    # System Variables
    $companyname = 'XXX';
    $systemurl = $params['systemurl'];
    $currency = $params['currency'];

        # Enter your code submit to the gateway...

$hashdata = ($key."|".$txnid."|".$amount."|".$productinfo."|".$firstname."|".$email."|"."|"."|"."|"."|"."|".$salt);

   $hash = hash("sha512", $hashdata);

$code = '<form method="post" action="https://secure.xxx.xxx" name="frmTransaction" id="frmTransaction" onSubmit="return validate()">
<input type="hidden" name="key" value="'.$key.'" />
<input type="hidden" name="mode" value="'.$gatewaymode.'" />
<input type="hidden" name="productinfo" value="'.$productinfo.'" />
<input type="hidden" name="txnid" value="'.$txnid.'" />
<input type="hidden" name="salt" value="'.$salt.'" />
<input type="hidden" name="name" value="'.$firstname.'" />
<input type="hidden" name="address" value="'.$address1.'" />
<input type="hidden" name="city" value="'.$city.'" />
<input type="hidden" name="state" value="'.$state.'" />
<input type="hidden" name="country" value="'.$country.'" />
<input type="hidden" name="postal_code" value="'.$postcode.'" />
<input type="hidden" name="ship_name" value="'.$firstname.'" />
<input type="hidden" name="ship_address" value="'.$address1.'" />
<input type="hidden" name="ship_city" value="'.$city.'" />
<input type="hidden" name="ship_state" value="'.$state.'" />
<input type="hidden" name="ship_country" value="'.$country.'" />
<input type="hidden" name="ship_postal_code" value="'.$postcode.'" />
<input type="hidden" name="ship_phone" value="'.$phone.'" />
<input type="hidden" name="email" value="'.$email.'" />
<input type="hidden" name="phone" value="'.$phone.'" />
<input type="hidden" name="amount" value="'.$amount.'" />
<input type="hidden" name="surl" value="https://xxx.xx/xxxx.php" />
<input type="hidden" name="furl" value="https://xxx.xx/xxx.php" />
<input type="hidden" name="Hash" value="'.$hash.'"/>
<input type="submit" value="Pay Now" />
</form>';

return $code;

}
?>

您正在寻找()函数。要创建sha512哈希,请按如下方式调用它:

hash('sha512', "the value to hash");

要了解您还可以使用哪些散列算法,请查看()函数

s应该是文本字符吗?因此,您需要将变量与
|
和salt连接起来,并将结果字符串通过sha512?没那么难,你到底有什么问题?还有,SHA512!==“加密”。这是一个杂烩!Tx供您建议和更正。您的公式是正确的,但根据他们的公式,所有值(如txnid、name等)都应使用sha512算法进行加密或散列,即sha512(值),但上述公式不能做到这一点。请使用另一种方法进行帮助。是否要将每个值(txnid)与
|
串联,然后将其全部散列在一起,还是要将每个值散列,然后将其串联?每个值与|串联,然后散列。在上面的公式中,如果字段为空,则每个字段应包含一个PIP。比如,如果我在上面的公式中没有udf,那么我就用一根管子替换它,即总共11根管子。@user157053,我也有同样的问题。。。同样的公式。。。如果你得到最后的答案,也帮我