VBS如何实现十六进制异或加密
这篇文章主要为大家展示了“VBS如何实现十六进制异或加密”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“VBS如何实现十六进制异或加密”这篇文章吧。
效果图:
代码都封装成函数了,方便调用:
复制代码 代码如下:
Key = "www-enun-net" '不要用数字
Wscript.echo now & ", 加密: "
MyData = ReadBin("test.jpg")
EnData = Encoder(MyData)
WriteBin "E_test.jpg", EnData
Wscript.echo now & ", 加密: "
Wscript.echo now & ", 解密: "
MyData = ReadBin("E_test.jpg")
UnData = Uncoder(MyData)
WriteBin "U_test.jpg", UnData
Wscript.echo now & ", 解密: "
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, 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
Uncoder = Uncoder & Chr(Split(K, "#")(j) Xor ("&H" & Mid(Data, i, 2)))
End If
Next
Next
End Function
以上是“VBS如何实现十六进制异或加密”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注编程网行业资讯频道!
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341