问题描述
我试图让使用贤者收费的形式集成了我的网站。我认为这会是相当简单的,但它没有证明,到目前为止是。我在.NET中工作,所以我从他们的支持页面下载.NET集成套件希望我能够看到它是如何工作和复制。
I'm trying to get use Sage Pay's Form Integration with my website. I thought it'd be fairly straightforward but it's not proving to be so far. I'm working in .NET so I downloaded the .NET Integration Kit from their support page hoping that I'd be able to see how it works and replicate it.
不幸的是,示例性试剂盒都远为它们是什么太复杂。它们应该是极其简单的项目,其允许工作原理是清楚地理解,而不是完整的,很好地封装解决方案。这是非常复杂的,当有一个code文件方法调用从几个人其中使用存储在Web.config文件中的值......对于教育的目的方法,它会容易得多,如果code被输入了长手在一个文件中,明确声明的设置值。当然,这不会是pretty,并希望没有像样的开发人员将复制这种笨拙的方法,但它会更容易地看到发生了什么事!
Unfortunately, the example kits are far too complex for what they are. They should be extremely simple projects which allow the workings to be clearly understood, not complete, nicely encapsulated solutions. It's very complicated when there are methods in one code file that call methods from a couple of others which use values stored in the Web.Config file... For the purposes of education it'd be much easier if the code was typed out long-hand in one file, with settings values explicitly declared. Of course it wouldn't be pretty and hopefully no decent developer would replicate such a clumsy approach, but it would make it easier to see what's going on!
总之,咆哮了。我的问题是,当我提出我的数据贤者支付我的错误
Anyway, rant over. My problem is that when I submit my data to Sage Pay I get the error
5068:加密方法不受此协议版本支持
要尽我加密我加入了SagePay.IntegrationKit.DotNet.DLL文件到我的项目,然后叫 SagePay.IntegrationKit.Cryptography.EncryptAndEn code
方法,产生看起来等同于从网站的工作例子产生一个加密的字符串。不幸的是,当我提交字符串贤者收费的服务器我得到的错误提及。
To do my encryption I added the SagePay.IntegrationKit.DotNet.DLL file to my project and then called the SagePay.IntegrationKit.Cryptography.EncryptAndEncode
method, which produces an encrypted string that looks the same as the one produced in the working example from the website. Unfortunately, when I submit the string to Sage Pay's server I get the error mentioned.
推荐答案
我没有投下来,但没有很多你的问题(例如源)这也许可以解释它继续下去。不过我刚刚拿到了这个code这个工作做的加密方式:
I didn't down vote, but there isn't a lot to go on in your question (e.g. source) which may explain it. However I've just got this working with this code to do the encryption:
public string SagePayEncryptAndEncode(string inputText, string key)
{
using (var AES = new RijndaelManaged())
{
// Set the mode, padding and block size for the key
AES.Padding = PaddingMode.PKCS7;
AES.Mode = CipherMode.CBC;
AES.KeySize = 128;
AES.BlockSize = 128;
// Convert key and input text into byte arrays
Byte[] keyAndIvBytes = UTF8Encoding.UTF8.GetBytes(key);
Byte[] inputBytes = UTF8Encoding.UTF8.GetBytes(inputText);
// Create streams and encryptor object
using (var memoryStream = new MemoryStream())
using (var cryptoStream = new CryptoStream(memoryStream, AES.CreateEncryptor(keyAndIvBytes, keyAndIvBytes), CryptoStreamMode.Write))
{
// Perform encryption
cryptoStream.Write(inputBytes, 0, inputBytes.Length);
cryptoStream.FlushFinalBlock();
// Get encrypted stream into byte array
var outBytes = memoryStream.ToArray();
// Manually close streams
memoryStream.Close();
cryptoStream.Close();
AES.Clear();
//return Convert.ToBase64String(outBytes);
return BitConverter.ToString(outBytes).Replace("-", String.Empty);
}
}
}
您则需要存储在隐藏地穴字段和prePEND'@'所产生的价值。
You then need to store the resulting value in the hidden 'Crypt' field and prepend '@'.
<input name='Crypt' type='hidden' value='@<InsertResultHere>' />
有一点要注意,它似乎只能用十六进制编码工作,而不是Base64编码的文件暗示。
One thing to note, it appears to only work using Hex encoding, and not Base64 encoding as the documentation implies.
希望这有助于!
这篇关于错误:&QUOT;加密方法不受此协议版本&QUOT的支持;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!