<%
function encrypt(thenumber)
on error resume next
dim n, szenc, t, hin, lon, i
n = cdbl((thenumber + 1570) ^ 2 – 7 * (thenumber + 1570) – 450)
if n < 0 then szenc = "r" else szenc = "j"
n = cstr(abs(n))
for i = 1 to len(n) step 2
t = mid(n, i, 2)
if len(t) = 1 then
szenc = szenc & t
exit for
end if
hin = (cint(t) and 240) / 16
lon = cint(t) and 15
szenc = szenc & chr(asc("m") + hin) & chr(asc("c") + lon)
next
encrypt = szenc
end function
function decrypt(thenumber)
on error resume next
dim e, n, sign, t, hin, lon, newn, i
e = thenumber
if left(e, 1) = "r" then sign = -1 else sign = 1
e = mid(e, 2)
newn = ""
for i = 1 to len(e) step 2
t = mid(e, i, 2)
if asc(t) >= asc("0") and asc(t) <= asc("9") then
newn = newn & t
exit for
end if
hin = mid(t, 1, 1)
lon = mid(t, 2, 1)
hin = (asc(hin) – asc("m")) * 16
lon = asc(lon) – asc("c")
t = cstr(hin or lon)
if len(t) = 1 then t = "0" & t
newn = newn & t
next
e = cdbl(newn) * sign
decrypt = clng((7 + sqr(49 – 4 * (-450 – e))) / 2 – 1570)
end function
%>
<html><body>
original number: 69 <br>
encrypt(69) returns: jnmqmoj8 <br>
decrypt("jnmqmoj8") returns: 69
<p>
another example using variables instead: <br>
encrypt(request.form("id")) <br>
encrypt(myvar) <br>
decrypt(request.querystring("id")) <br>
decrypt("jnmqmoj8") <br>
decrypt(myvar)
</body></html>
