Nemme point
Hej alleJeg forsøger at skrive et asp-script om til asp.net, men er ingen ørn...
Hvordan er det lige jeg kalder en funktion EnDeCrypt() og sætter værdien ind i min form ?
Login.aspx (al kode):
<%@ Page Language="VB" codebehind="login.aspx.vb" autoeventwireup="false" %>
<form runat="server" action="http://www.xxx.dk/login/" method="post">
<input type="hidden" id="timeid" name="timeid" value="<% = now() %>" />
<input type="hidden" name="wID" value="<% =EnDeCrypt(now(),pwd) %>" />
<input type="submit" value="Klik her for at logge ind" />
</form>
Og login.aspx.vb (al kode) :
Public Class login Inherits System.Web.UI.Page
pwd = "qwerty"
Dim sbox(255)
Dim key(255)
Sub RC4Initialize(strPwd)
dim tempSwap
dim a
dim b
intLength = len(strPwd)
For a = 0 To 255
key(a) = asc(mid(strpwd, (a mod intLength)+1, 1))
sbox(a) = a
next
b = 0
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
Function EnDeCrypt(plaintxt, psw)
dim temp
dim a
dim i
dim j
dim k
dim cipherby
dim cipher
i = 0
j = 0
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
EnDeCrypt = cipher
End Function
End Class
Det bør være ret nemt, hvis man ellers kan asp.net...