Kig her:
http://www.4guysfromrolla.com/webtech/010100-1.shtmlMen ellers kan evt. gøres sådan:
Din ASP-fil:
<%
<!-- #include="EnDeCrypt.asp" --->
Response.Cookies("UsernameCookie") = Request.Form("brugernavn")
Response.Cookies("PasswordCookie") = EnDeCrypt(Request.Form("Password"))
Response.Cookies("UIDCookie") = rs("id")
Response.Cookies("UIDCookie").expires = Now() + 365
Response.Cookies("UsernameCookie").expires = Now() + 365
Response.Cookies("PasswordCookie").expires = Now() + 365
Response.Cookies("RememberMeCookie").expires = Now() + 365
Session("login") = 1
Session("brugernavn") = rs("brugernavn")
Session("uid") = rs("id")
Session("admin") = rs("admin")
response.redirect "admin.asp"
%>
-----------------------------------------------------------------------------------
EnDeCrypt.asp:
<%
Dim sbox(255)
Dim key(255)
Sub RC4Initialize(strPwd) ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'::: This routine called by EnDeCrypt function. Initializes the :::
'::: sbox and the key array) ::: ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
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) ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'::: This routine does all the work. Call it both to ENcrypt :::
'::: and to DEcrypt your data. ::: ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
dim temp
dim a
dim i
dim j
dim k
dim cipherby
dim cipher
dim psw = "en dum lille kode til kryptering"
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
%>