欢迎光临
我们一直在努力

再来一套加解密字符串的function

建站超值云服务器,限时71元/月

<%
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>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 再来一套加解密字符串的function
分享到: 更多 (0)

相关推荐

  • 暂无文章