<%
Key = "SIAMFOCUS"
Function Encrypt(Text)
For Char = 1 To LEN(Text)
TextCharCode = ASC(MID(Text,Char,1))
PasswordCharCode = ASC(MID(Key,(Char MOD LEN(Key) + 1),1))
NewCharCode = TextCharCode + PasswordCharCode
If NewCharCode > 255 Then NewCharCode = NewCharCode - 255
Encrypt = Encrypt & CHR(NewCharCode)
NEXT
End function
Function Decrypt(Text)
For Char = 1 To LEN(Text)
CodeCharCode = ASC(MID(Text,Char,1))
PasswordCharCode = ASC(MID(Key,(Char MOD LEN(Key) + 1),1))
OriginalCharCode = CodeCharCode - PasswordCharCode
If OriginalCharCode < 1 Then OriginalCharCode = OriginalCharCode + 255
Decrypt = Decrypt & CHR(OriginalCharCode)
NEXT
End function
TestText = "เข้ารหัส siamfocus.com"
EncryptText = Encrypt(TestText)
DecryptText = Decrypt(EncryptText)
Response.Write "Text : "&TestText&"<br>"
Response.Write "Encrypt : "&EncryptText&"<br>"
Response.Write "Decrypt : "&DecryptText&"<hr>"
%>