sagepay 암호화는 VB에서만 문서화되므로 xor 암호화를 C#으로 작성하려고합니다.C# Sagepay XOR 암호화
VB에서 코드는 다음과 같습니다 지금까지 내가이 줄 무엇을하고 있는지 이해하지 못했다되어
public static String SimpleXOR(String strIn, String strKey)
{
Int32 iInIndex, iKeyIndex;
String strReturn;
iInIndex = 1;
iKeyIndex = 1;
strReturn = "";
while (iInIndex <= strIn.Length)
{
strReturn = strReturn & Strings.Chr(Strings.Asc(Strings.Mid(strIn, iInIndex, 1))^Strings.Asc(Strings.Mid(strKey, iKeyIndex, 1)));
iInIndex = iInIndex + 1;
if (iKeyIndex == strKey.Length) iKeyIndex = 0;
iKeyIndex = iKeyIndex + 1;
}
}
문제로이를 변환 한
Public Shared Function simpleXor(ByVal strIn As String, ByVal strKey As String) As String
Dim iInIndex As Integer
Dim iKeyIndex As Integer
Dim strReturn As String
If Len(strIn) = 0 Or Len(strKey) = 0 Then
simpleXor = ""
Exit Function
End If
iInIndex = 1
iKeyIndex = 1
strReturn = ""
'** Step through the plain text source XORing the character at each point with the next character in the key **
'** Loop through the key characters as necessary **
Do While iInIndex <= Len(strIn)
strReturn = strReturn & Chr(Asc(Mid(strIn, iInIndex, 1)) Xor Asc(Mid(strKey, iKeyIndex, 1)))
iInIndex = iInIndex + 1
If iKeyIndex = Len(strKey) Then iKeyIndex = 0
iKeyIndex = iKeyIndex + 1
Loop
simpleXor = strReturn
End Function
strReturn = strReturn & Chr(Asc(Mid(strIn, iInIndex, 1)) Xor Asc(Mid(strKey, iKeyIndex, 1)))
그래서 나는 VB에서 C# converter로 돌렸고 위의 것을 얻었다. 하지만 분명히 내가 알고있는 한 유효한 C# 코드가 아닙니다.
아무도 도와 줄 수 있습니까?
첫째, 현재 System.Globalization.CultureInfo.CurrentCulture.TextInfo.ANSICodePage을 잡아 :
C#에서
지불 프로세서가 자체 암호화를 발명 한 경우 10 피트 극으로 만지지는 않습니다. – SLaks
@SLaks SagePay는 일종의 거물입니다. –