时间:2021-05-22
效果图:
代码都封装成函数了,方便调用:
复制代码 代码如下:
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
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
ox是十六进制,0x是十六进制的开始符,16进制就是逢16进1。一般用数字0到9和字母A到F(或a~f)表示,其中:A到F表示10到15,这些称作十六进制数字。
本文实例讲述了C++实现十六进制字符串转换为十进制整数的方法。分享给大家供大家参考。具体实现方法如下:/**将十六进制数字组成的字符串(包含可选的前缀0x或0X
于是研究了一会。写出个粗糙的DEMO。exe2hex.vbs//xiaolu写的exe2vbs,我修改成直接拖放,转成十六进制=================
byte型转换十六进制字符串/***byte型转换十六进制*@paramb*@returns{string}*@constructor*/constBytes2
什么是十六进制?十六进制怎么转换? 十六进制的定义 16进制即逢16进1,其中用A,B,C,D,E,F(字母不区分大小写)这六个字母来分别表示10,11