VBS如何实现加密解密

发布时间:2021-10-12 10:03:43 作者:小新
来源:亿速云 阅读:402

这篇文章主要为大家展示了“VBS如何实现加密解密”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“VBS如何实现加密解密”这篇文章吧。

用法:

1.copy下面代码至文本文档
2.将文件后缀名改为.vbs
3.双击运行

代码如下:


Ans = InPutBox("请输入要执行的操作:1.加密,2.解密,3.退出。")
Ans = Int(Ans)
If Ans =1 Then
set fso=createobject("scripting.filesystemobject")
Set objDialog = CreateObject("UserAccounts.CommonDialog")
objDialog.Filter = "vbs File|*.vbs|All Files|*.*"
objDialog.InitialDir = ""
objDialog.ShowOpen
strLoadFile = objDialog.FileName
if not strLoadFile = "" then
set op=fso.opentextfile(strLoadFile)
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(strLoadFile,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"
msgbox "加密成功",,"提示"
end if
end if
If Ans = 2 Then
Set objfs=CreateObject("scripting.filesystemobject")
Set objDialog=CreateObject("UserAccounts.CommonDialog")
objDialog.Filter="vbs File|*.vbs|All Files|*.*"
objDialog.InitialDir = ""
objDialog.ShowOpen
strLoadFile = objDialog.FileName
if not strLoadFile = "" then
set objf=objfs.opentextfile(strLoadFile)
str=objf.ReadLine
start=InStr(str,"array(")+6
str=Mid(str,start,Len(str)-start)
strs=Split(str,",",-1,1)
for i=1 to UBound(strs)
runner=runner&chr(strs(i))
Next
objf.Close
Set objf=objfs.OpenTextFile(strLoadFile,2)
objf.Write runner
MsgBox "解密成功",,"提示"
end if
end if
if Ans = 3 Then
Wscript.Quit
End If


注意上面的代码只有在winxp下使用,原因可以参考https://www.jb51.net/article/26390.htm因为那个选择文件功能不能使用而已,下面我们修改下,让他支持win2000,win2003系统,我们可以通过拖动文件到这个vbs上即可。
亿速云修改的加强版本

复制代码 代码如下:


If WScript.Arguments.Count=0 Then WScript.Quit
strLoadFile=WScript.Arguments(0)
Ans = InPutBox("请输入要执行的操作:1.加密,2.解密,3.退出。")
Ans = Int(Ans)
If Ans =1 Then
set fso=createobject("scripting.filesystemobject")
if not strLoadFile = "" then
set op=fso.opentextfile(strLoadFile)
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(strLoadFile,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"
msgbox "加密成功",,"提示"
end if
end if
If Ans = 2 Then
Set objfs=CreateObject("scripting.filesystemobject")
if not strLoadFile = "" then
set objf=objfs.opentextfile(strLoadFile)
str=objf.ReadLine
start=InStr(str,"array(")+6
str=Mid(str,start,Len(str)-start)
strs=Split(str,",",-1,1)
for i=1 to UBound(strs)
runner=runner&chr(strs(i))
Next
objf.Close
Set objf=objfs.OpenTextFile(strLoadFile,2)
objf.Write runner
MsgBox "解密成功",,"提示"
end if
end if
if Ans = 3 Then
Wscript.Quit
End If

以上是“VBS如何实现加密解密”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!

推荐阅读:
  1. Python如何实现aes加密解密
  2. PHP如何实现加密解密

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

vbs

上一篇:如何从零开始搭建自动部署docker环境

下一篇:如何理解Spring Bean IOC、AOP的循环依赖

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》