vbs加密vbs
⑴ vbs加密算法问题
将asc转换为十六进制即可,位数统一,还可以忽略负号。
FunctionGenerateCode(strText)
'输入字符串(strText),返回十六进制ANSI编码
Dimi
Fori=1toLen(strText)
GenerateCode=GenerateCode&Hex(Asc(Mid(strText,i,1)))
Next
EndFunction
FunctionGetText(strCode)
'输入十六进制ANSI编码(strCode),返回字符串原文
Dimi,strTmp
Fori=1toLen(strCode)Step2
strTmp="&h"&Mid(strCode,i,2)
IfCInt(strTmp)<128Then
GetText=GetText&Chr(strTmp)
Else
i=i+2
GetText=GetText&Chr(strTmp&Mid(strCode,i,2))
EndIf
Next
EndFunction
这是我自己加密字符串用的。符合你的要求,密文为十六进制无分隔符的连续字符串,ASCII字符(0-127)转换为2位,其它ANSI字符(256-65535)转换为4位。
此算法是本着平衡 [加密/解密的代码量] 与 [密文长度] 为宗旨编写的。
不知道你加密想要干什么,但我还是建议你:
不要想着进一步通过运算等方式“加密”,因为在vbs下解密算法是明文,一切加密在懂行者看来都是没意义的。在我看来,vbs的加密充其量也就是稍微隐藏下字符串或代码,不被人一眼就看到意图而已。所以说,我这个算法就够用了。
如果想进一步隐藏代码,可以自己网络[ Scripting.Encoder ]。不出意外的,这个也可以被解密。
代码中有不懂的地方可以追问。
⑵ VBS有没有加密代码
dim pwd
pwd = inputbox("请输入密码","请输入密码")  括号内两个引号内容分别为弹出输入对话框的lable和caption,可自行修改.
if pwd = "*****" then  '"*****"为密码
msgbox "right"  '自行修改
else 
msgbox "wrong"  '自行修改
end if
此脚本利用IF判断,密码必须在脚本中设。
对话可根据需求增加msgbox的数量
⑶ VBS的加密跟解密
VBS加密:
复制以下代码,用记事本另存为,“VBS加密” 保存。
set fso=createobject("scripting.filesystemobject")
scf=inputbox("请输入要加密的脚本文件名","VBS加密程序","*.vbs")
set op=fso.opentextfile(scf)
dow=13
do while op.atendofstream=false
        line=op.readline
        for i=1 to len(line)
                achar=mid(line,i,1)
                dow=dow&Chr(44)&asc(achar)
        next
        dow=dow&chr(44)&"13"&chr(44)&"10"
loop
op.close
set op=fso.opentextfile(scf,2)
op.write "strs=array("&dow&")"&chr(13)&chr(10)&_
         "for i=1 to UBound(strs)"&chr(13)&chr(10)&_
         "        runner=runner&chr(strs(i))"&chr(13)&chr(10)&_
         "next"&chr(13)&chr(10)&_
         "Execute runner"
VBS解密
复制以下代码,用记事本另存为,“VBSVBS解密” 保存。
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
