0

I am trying to include a cipher encryption to my text, issue is I am coding in asp and the file is in .vb

here is the .vb file :

Imports Microsoft.VisualBasic

Namespace RCMAPIs
  Public Class rmsEncryptcl
    Dim sbox(255) As Integer
    Dim key(255) As Integer

    Public Sub RC4Initialize(ByVal strPwd As String)
      Dim tempSwap As String = ""
      Dim a As Integer = 0
      Dim b As Integer = 0

      Dim intLength As Integer = Len(strPwd)
      For a = 0 To 255
        key(a) = Asc(Mid(strPwd, (a Mod intLength) + 1, 1))
        sbox(a) = a
      Next

      For a = 0 To 255
        b = (b + sbox(a) + key(a)) Mod 256
        tempSwap = sbox(a)
        sbox(a) = sbox(b)
        sbox(b) = tempSwap
      Next

    End Sub

    Public Function EnDeCrypt(ByVal plaintxt As String, ByVal psw As String) As String
      Dim temp As String = ""
      Dim a As Integer = 0
      Dim i As Integer = 0
      Dim j As Integer = 0
      Dim k As Integer = 0
      Dim cipherby As String = ""
      Dim cipher As String = ""

      RC4Initialize(psw)

      For a = 1 To Len(plaintxt)
        i = (i + 1) Mod 256
        j = (j + sbox(i)) Mod 256
        temp = sbox(i)
        sbox(i) = sbox(j)
        sbox(j) = temp

        k = sbox((sbox(i) + sbox(j)) Mod 256)

        cipherby = Asc(Mid(plaintxt, a, 1)) Xor k
        cipher = cipher & Chr(cipherby)
      Next
      Return cipher
    End Function

  End Class
End Namespace

and here is what I need to achieve :

<%    
dim psw, txt, x
x = "Z&#159;*ry&#239;t&#202;bYP&#234;h&#132;&#196;"
psw = "ZA08i6"
x = EnDeCrypt(x, psw)
Response.Write x
%>

so anyone know how I can make my .asp file understand the function and work with it ? I am a little lost.

user692942
  • 16,398
  • 7
  • 76
  • 175
Skyliquid
  • 374
  • 1
  • 5
  • 23

0 Answers0