将.vb文件导入.asp

时间:2014-03-01 12:39:55

标签: vb.net asp-classic

我正在尝试在我的文本中加入密码加密,问题是我在asp编码,文件在.vb中

这是.vb文件:

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

这就是我需要实现的目标:

<%    
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
%>

所以任何人都知道如何让我的.asp文件了解该功能并使用它?我有点失落。

0 个答案:

没有答案