Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement hexadecimal XOR encryption in VBS

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly shows you "VBS how to achieve hexadecimal XOR encryption", 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 hexadecimal XOR encryption" this article.

Effect picture:

The code is encapsulated into functions, making it easy to call:

The copy code is as follows:

Key = "www-enun-net" 'Don't use numbers

Wscript.echo now & ", encryption:"

MyData = ReadBin ("test.jpg")

EnData = Encoder (MyData)

WriteBin "E_test.jpg", EnData

Wscript.echo now & ", encryption:"

Wscript.echo now & ", decrypt:"

MyData = ReadBin ("E_test.jpg")

UnData = Uncoder (MyData)

WriteBin "U_test.jpg", UnData

Wscript.echo now & ", decrypt:"

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 = Nothing

Set ObjXML = Nothing

End Function

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 = Nothing

Set ObjXML = Nothing

End Function

Function Encoder (Data)

Dim K, M

For n = 0 To Len (Key)-1

K = K & Asc (Left (Right (key, Len (Key)-n), 1)) & "#"

Next

Data = UCase (Data)

For I = 0 To Len (Data)-1

M = Left (Right (Mid (Data, iTunes 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 (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

Uncoder = Uncoder & Chr (Split (K, "#") (j) Xor ("& H" & Mid (Data, I, 2)

End If

Next

Next

End Function

The above is all the contents of the article "how to achieve hexadecimal XOR encryption in 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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report