The file should not be too large, preferably not more than KB, the key do not use numbers, do not want to change. Theoretically supports any binary file format
Effect Chart:
The code is encapsulated into functions for easy invocation:
Copy Code code as follows:
Key = "Www-enun-net" ' Don't use numbers
WScript.Echo Now &, Encrypting: "
MyData = Readbin ("test.jpg")
Endata = Encoder (MyData)
Writebin "E_test.jpg", Endata
WScript.Echo Now &, Encrypting: "
WScript.Echo Now &, Decrypting: "
MyData = Readbin ("e_test.jpg")
Undata = Uncoder (MyData)
Writebin "U_test.jpg", Undata
WScript.Echo Now &, Decrypting: "
Function Readbin (FileName)
dim Stream, Objxml, Mynode
set objxml = CreateObject (" Microsoft.XMLDOM ")
set Mynode = objxml.createelement (" binary ")
set Stream = CreateObject (" ADODB ". Stream ")
mynode.datatype =" Bin.hex "
stream.type = 1
stream.open
Stream.loadfromfile FileName
mynode.nodetypedvalue = stream.read
stream.close
ReadBin = Mynode.text
set mynode = Nothing
set Stream = no
set objxml = Nothing
End function< /p>
Function writebin (FileName, Bufferdata)
dim Stream, Objxml, Mynode
set objxml = CreateObject (" Microsoft.XMLDOM ")
set Mynode = objxml.createelement (" binary ")
set Stream = CreateObject (" ADODB ". Stream ")
mynode.datatype =" Bin.hex "
mynode.text = bufferdata
stream.type = 1
Stream.open
stream.write mynode.nodetypedvalue
stream.savetofile FileName, 2
Stream.Close
set stream = Nothing
set mynode = no
set objxml = Nothing
End Function
Function encoder (Data)
dim K, M
for n = 0 to Len (Key)-1
k = k & Asc ( Key, Len (key)-N, 1) & "#"
next
data = UCase (data)
for i = 0 to Len (data)-1
& nbsp M = Left (right (data, i+1, 1), Len (data)-I, 1)
for j = 0 to Len (Key)-1
if i Mod Len (Key) = j Then
encoder = encoder & Hex ((ASC (M) Xor Split (K, "#") (j))
end If
next
next
End Function
Function Uncoder (Data)
dim k
for n = 0 to Len (Key)-1
k = k & "#" & Asc (left (Right (key, Len (key)-N), 1) & "#X"
next
k = K & k
data = UCase (data)
for i = 1 to Len (Data) Step 2
for j = 1 to Len (key) * 2
if i Mod Len (key) *2 = j Then
&NBSP;&NBSP;&NBSP;&NB Sp Uncoder = Uncoder & Chr (Split (K, "#") (j) Xor ("&h" & Mid (Data, I, 2))
end If
next
next
End Function