Note that there are some explanatory texts on larger screens.

plurals
  1. PODescrypt SagePay string vb.net
    primarykey
    data
    text
    <p>I have been having some problems trying to decrypt the string returned back from SagePay.</p> <p>I used their asp.net kit which included the encrypt and decrypt functions using base64 - sending the information to SagePay is not a problem but I am having a number of problems trying to descrypt the string.</p> <p>Here is the function I am using to descypt:</p> <p><code> Private Function base64Decode(ByVal strEncoded As String) As String</p> <pre><code> Dim iRealLength As Integer Dim strReturn As String Dim iBy4 As Integer Dim iIndex As Integer Dim iFirst As Integer Dim iSecond As Integer Dim iThird As Integer Dim iFourth As Integer If Len(strEncoded) = 0 Then base64Decode = "" Exit Function End If '** Base 64 encoded strings are right padded to 3 character multiples using = signs ** '** Work out the actual length of data without the padding here ** iRealLength = Len(strEncoded) Do While Mid(strEncoded, iRealLength, 1) = "=" iRealLength = iRealLength - 1 Loop '** Non standard extension to Base 64 decode to allow for + sign to space character substitution by ** '** some web servers. Base 64 expects a +, not a space, so convert vack to + if space is found ** Do While InStr(strEncoded, " ") &lt;&gt; 0 strEncoded = Left(strEncoded, InStr(strEncoded, " ") - 1) &amp; "+" &amp; Mid(strEncoded, InStr(strEncoded, " ") + 1) Loop strReturn = "" '** Convert the base 64 4x6 byte values into 3x8 byte real values by reading 4 chars at a time ** iBy4 = (iRealLength \ 4) * 4 iIndex = 1 Do While iIndex &lt;= iBy4 iFirst = arrBase64DecMap(Asc(Mid(strEncoded, iIndex + 0, 1))) 'iFirst = CType(System.Convert.ToByte(CType(Mid(strEncoded, iIndex + 0, 1), Char)), Integer) iSecond = arrBase64DecMap(Asc(Mid(strEncoded, iIndex + 1, 1))) 'iSecond = CType(System.Convert.ToByte(CType(Mid(strEncoded, iIndex + 1, 1), Char)), Integer) iThird = arrBase64DecMap(Asc(Mid(strEncoded, iIndex + 2, 1))) 'iThird = CType(System.Convert.ToByte(CType(Mid(strEncoded, iIndex + 2, 1), Char)), Integer) iFourth = arrBase64DecMap(Asc(Mid(strEncoded, iIndex + 3, 1))) 'iFourth = CType(System.Convert.ToByte(CType(Mid(strEncoded, iIndex + 3, 1), Char)), Integer) strReturn = strReturn + CType(System.Convert.ToChar(((iFirst * 4) And 255) + ((iSecond \ 16) And 3)), String) 'Chr(((iFirst * 4) And 255) + ((iSecond \ 16) And 3)) strReturn = strReturn + CType(System.Convert.ToChar(((iSecond * 16) And 255) + ((iThird \ 4) And 15)), String) 'Chr(((iSecond * 16) And 255) + ((iThird \ 4) And 15)) strReturn = strReturn + CType(System.Convert.ToChar(((iThird * 64) And 255) + (iFourth And 63)), String) 'Chr(((iThird * 64) And 255) + (iFourth And 63)) iIndex = iIndex + 4 Loop '** For non multiples of 4 characters, handle the = padding ** If iIndex &lt; iRealLength Then iFirst = arrBase64DecMap(Asc(Mid(strEncoded, iIndex + 0, 1))) iSecond = arrBase64DecMap(Asc(Mid(strEncoded, iIndex + 1, 1))) strReturn = strReturn &amp; Chr(((iFirst * 4) And 255) + ((iSecond \ 16) And 3)) If iRealLength Mod 4 = 3 Then iThird = arrBase64DecMap(Asc(Mid(strEncoded, iIndex + 2, 1))) strReturn = strReturn &amp; Chr(((iSecond * 16) And 255) + ((iThird \ 4) And 15)) End If End If base64Decode = strReturn End Function </code></pre> <p></code></p> <p>I don't think the web server is trying to encode anything as there are no + symbols within the url string and I have just glanced over the two to compair they are the same.</p> <p>This returns a blank string whereas when I use the sections commented out in the first loop i get a really weired string back and when I use their simpleXor function it just returns complete nonsense.</p> <p>There support is a bit useless as they "are not programmers"! So I am hoping someone can help me out who has used SagePay before.</p> <p>Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload