2013-11-21 59 views
1

我得到错误mcrypt_encrypt():IV参数必须与第二行上块大小一样长。PHP错误:mcrypt_encrypt():IV参数必须与块大小一样长

$data = "Currency=GBP&SuccessURL=test&FailureURL=test&VendorEMail=test&SendEMail=1&eMailMessage=&Amount=&Description=&CustomerName=test test&CustomerEMail=test&BillingSurname=test&BillingFirstnames=test&BillingAddress1=test&BillingAddress2=test&BillingCity=test&BillingPostCode=test&BillingCountry=test&BillingPhone=test&DeliverySurname=test&DeliveryFirstnames=test&DeliveryAddress1=test&DeliveryAddress2=test&DeliveryCity=test&DeliveryPostCode=test&DeliveryCountry=test\u0003\u0003\u0003"; 
    $encrypted = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, 'test', $data, MCRYPT_MODE_CBC, 'test'); 

回答

1

IV参数不是mcrypt_encrypt()作为我认为这将是第4参数。它实际上是最后一个参数,第5个参数。
这里指定http://php.net/manual/en/function.mcrypt-encrypt.phpiv

此实例的$ data数据块大小为16,所以mcrypt_encrypt()中的最后一个参数需要为16个字符长。

blocksize是数据字符串应该被整除的数字,否则它的最后部分需要被填充到它才能被整除。

2

在我的情况下,它也给了同样的错误。我之前使用的是实际的密码。但是,当我使用加密的密码,它的工作。在sagepay.php第54行中,protected $ encryptPassword =“”。在这里我使用了加密的密码,这是我在测试帐户中获得的。现在它的工作。
这可能会有所帮助。
谢谢

+0

加密密码意味着如何加密密码可以详细说明一下吗? – comeback4you

+0

你不需要加密密码。你会得到你的acc。 – Sajal

+0

thanx你是对的...我得到了密码。你可以请分享你的电子邮件ID。 – comeback4you

相关问题