VBS 十六進(jìn)制異或加密實(shí)現(xiàn)代碼
來(lái)源:易賢網(wǎng) 閱讀:1425 次 日期:2014-05-09 16:53:27
溫馨提示:易賢網(wǎng)小編為您整理了“VBS 十六進(jìn)制異或加密實(shí)現(xiàn)代碼”,方便廣大網(wǎng)友查閱!

文件不要過(guò)大,最好不要超過(guò) 100 KB,密鑰不要用數(shù)字,不想改了。理論上支持任何二進(jìn)制文件格式

效果圖:

1.jpg

代碼都封裝成函數(shù)了,方便調(diào)用:

代碼如下:

Key = "www-enun-net" '不要用數(shù)字

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

更多信息請(qǐng)查看IT技術(shù)專欄

更多信息請(qǐng)查看腳本欄目
易賢網(wǎng)手機(jī)網(wǎng)站地址:VBS 十六進(jìn)制異或加密實(shí)現(xiàn)代碼
由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請(qǐng)考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!

2025國(guó)考·省考課程試聽(tīng)報(bào)名

  • 報(bào)班類型
  • 姓名
  • 手機(jī)號(hào)
  • 驗(yàn)證碼
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡(jiǎn)要咨詢 | 簡(jiǎn)要咨詢須知 | 加入群交流 | 手機(jī)站點(diǎn) | 投訴建議
工業(yè)和信息化部備案號(hào):滇ICP備2023014141號(hào)-1 云南省教育廳備案號(hào):云教ICP備0901021 滇公網(wǎng)安備53010202001879號(hào) 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號(hào)
云南網(wǎng)警備案專用圖標(biāo)
聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號(hào):hfpxwx
咨詢QQ:526150442(9:00—18:00)版權(quán)所有:易賢網(wǎng)
云南網(wǎng)警報(bào)警專用圖標(biāo)