ASP代碼一般是明文,很少有加密的,MS有個工具Script Encoder可以加密,這個東東可以微軟官方網(wǎng)站免費下載,而且還有詳細(xì)使用說明,但是經(jīng)過它加密后的文件會有<%@ language = vbscript.encode %>,管理員看到這句話就知道這個asp文件被加密了。而且也有相關(guān)的解密文件。 本文提供一種簡單的方法,可以加密ASP代碼,主要思路是將代碼做些運算,比如將全部代碼移動一位,基本上就算加密了,主要的加解密函數(shù)如下:
function UnEncode(temp) but=1 for i =1 to len(temp) if mid(temp,i,1)<>"湯" then pk=asc(mid(temp,i,1))-but if pk>126 then pk=pk-95 elseif pk<32 then pk=pk+95 end if a=a&chr(pk) else a=a&vbcrlf end if next UnEncode=a end function
function Encode(temp) but=1 cc=replace(temp,vbcrlf,"湯") for i= 1 to len(cc) if mid(cc,i,1)<>"湯" then pk=asc(mid(cc,i,1))+but if pk>126 then pk=pk-95 elseif pk<32 then pk=pk+95 end if a=a&chr(pk) else a=a&"湯" end if next ’a=replace(a,"""","""""") Encode=a end function