How to realize encryption and decryption by VBS
This article mainly shows you "VBS how to achieve encryption and decryption", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "VBS how to achieve encryption and decryption" this article.
Usage:
1.copy the following code to the text document
two。 Change the file suffix to .vbs
3. Double-click to run
The code is as follows:
Ans = InPutBox ("Please enter the action to be performed: 1. Encryption, 2. Decryption, 3. Exit.")
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 iTunes 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 iTunes 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 "encryption successful", "prompt"
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)
For iTunes 1 to UBound (strs)
Runner=runner&chr (strs (I))
Next
Objf.Close
Set objf=objfs.OpenTextFile (strLoadFile,2)
Objf.Write runner
MsgBox "decryption successful", "prompt"
End if
End if
If Ans = 3 Then
Wscript.Quit
End If
Note that the above code can only be used under winxp, the reason can refer to https://www.jb51.net/article/26390.htm because that select file function can not be used, below we modify, let him support the win2000,win2003 system, we can drag the file to this vbs.
Modified enhanced version
The copy code is as follows:
If WScript.Arguments.Count=0 Then WScript.Quit
StrLoadFile=WScript.Arguments (0)
Ans = InPutBox ("Please enter the action to be performed: 1. Encryption, 2. Decryption, 3. Exit.")
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 iTunes 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 iTunes 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 "encryption successful", "prompt"
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)
For iTunes 1 to UBound (strs)
Runner=runner&chr (strs (I))
Next
Objf.Close
Set objf=objfs.OpenTextFile (strLoadFile,2)
Objf.Write runner
MsgBox "decryption successful", "prompt"
End if
End if
If Ans = 3 Then
Wscript.Quit
End If
The above is all the contents of the article "how to encrypt and decrypt VBS". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!