Du kan jo kigge på disse svar om kryptering:
http://eksperten.dk/spm/459358Et andet eksempel er dette:
<%@ Language=VBScript %>
<%
Dim i, sValid, sInvalid
sInvalid = "bcdfghijklopqruvwxyz0134678BCEFGHIJKLMOQSVWXYZ"
sValid = "2RDPsANtame95nUT"
randomize
function int2hex(iNum)
Dim sHex
sHex = mid(sValid,cint(iNum \ 16)+1,1) & mid(sValid,cint(iNum mod 16)+1,1)
int2hex = sHex
End Function
function hex2int(sHex)
Dim iNum
iNum = (instr(1,sValid,left(sHex,1))-1)*16 + instr(1,sValid,right(sHex,1))-1
hex2int = iNum
End Function
Function fCrypt(sClave,sTmp)
Dim iKeyChar, iStringChar, i, ii, sEncrypted, iCryptChar
sEncrypted = ""
ii = 1
for i = 1 to Len(sTmp)
iKeyChar = Asc(mid(sClave,ii,1))
iStringChar = Asc(mid(sTmp,i,1))
iCryptChar = iKeyChar Xor iStringChar
sEncrypted = sEncrypted & int2hex(iCryptChar)
ii = ii + 1
if ii > len(sClave) then ii = 1 end if
next
for i=1 to len(sEncrypted)
ii = cint(rnd*(len(sEncrypted)))+1
sEncrypted = left(sEncrypted,ii-1) & mid(sInvalid,cint(rnd*(len(sInvalid)))+1,1) & right(sEncrypted,len(sEncrypted)-(ii-1))
next
fCrypt = sEncrypted
End Function
Function fDecrypt(sClave, sTmp)
Dim iKeyChar, iStringChar, i, ii, sEncrypted, iCryptChar, sTmp2
sEncrypted = ""
sTmp2 = ""
for i = 1 to Len(sTmp)
if instr(1,sValid,mid(sTmp,i,1)) > 0 then
sTmp2 = sTmp2 & mid(sTmp,i,1)
end if
next
ii = 1
for i = 1 to Len(sTmp2)/2
iKeyChar = Asc(mid(sClave,ii,1))
iStringChar = hex2int(mid(sTmp2,((i-1)*2)+1,2))
iCryptChar = iKeyChar Xor iStringChar
sEncrypted = sEncrypted & chr(iCryptChar)
ii = ii + 1
if ii > len(sClave) then ii = 1 end if
next
fDecrypt = sEncrypted
End Function
%>
<HTML>
<HEAD>
</head>
<html>
<%
response.write(fCrypt("this is my key","This is what i want to encrypt") & "<br>")
Response.Write(fDecrypt("this is my key",fCrypt("this is my key","This is what i want to encrypt")))
'sUser = "John"
'response.cookies("User") = fCrypt("This is the KEY", sUser)
sUser = fDecrypt("This is the KEY", request.cookies("User"))
response.write sUser
%>
:-) karsten_larsen