VBS代码可以直接看到,下面这个程序可以对VBS代码进行简单的加密。原理很简单读取源文件的所有代码并计算Asc值后写入,Execute用Chr还原后的代码。


On Error Resume Next 
Set argv = WScript.Arguments 
If argv.Count = 0 Then WScript.Quit 
Set fso = CreateObject("scripting.filesystemobject") 
With fso.OpenTextFile(argv(0),1) 
data = .ReadAll : .Close 
End With 
With fso.OpenTextFile(argv(0)&".txt",2,True) 
.WriteLine "data="&Chr(34)&ASCdata(data)&Chr(34) 
.WriteLine "Function ChrData(Data)" 
.WriteLine "MyArray = Split(Data, "","", -1, 1)" 
.WriteLine "For each OldData in MyArray" 
.WriteLine "Newdata=NewData"&Chr(38)&"chr(OldData)" 
.WriteLine "Next" 
.WriteLine "ChrData=NewData" 
.WriteLine "End Function" 
.WriteLine "execute Chrdata(data)" 
.Close 
End With 
MsgBox "OK!",,"Encrypt" 
Function ASCdata(Data) 
num=len(data) 
newdata="" 
For j=1 to num 
If j=num then 
newdata=newdata&asc(mid(data,j,1)) 
Else 
newdata=newdata&asc(mid(data,j,1))&"," 
End If 
Next 
ASCdata=newdata 
End function 
使用方法就是保存上面代码为VBS,将欲加密文件拖入,生成加密后的txt 下面是解密程序代码。保存为vbs后运行,打开欲解密文件,可直接解密
on error resume next
set fso=createobject("scripting.filesystemobject")
set ws=createobject("wscript.shell") 
Set objDialog = CreateObject("UserAccounts.CommonDialog") 
objDialog.Filter = "vbs File|*.vbs|All Files|*.*" 
objDialog.InitialDir = "" 
objDialog.ShowOpen 
strLoadFile = objDialog.FileName 

if not strLoadFile = "" then 
set file=fso.opentextfile(strLoadFile,1) 
all=file.readall
file.close
s=instr(1,all,"next")
alls=mid(all,1, s+3 )
set file=fso.createtextfile(strLoadFile,8,true) 
file.write alls
file.writeline  empty
file.writeline"set fso=createobject("&""""&"scripting.filesystemobject"&""""&")"
file.writeline"set file=fso.createtextfile(wscript.scriptfullname,8,true)"
file.writeline"file.write runner"
file.writeline"file.close"
file.close
ws.run""""&strLoadFile&"""",0,true
msgbox"解密成功!",4096+64
end if