vbs 十六進(jìn)制異或加密實現(xiàn)代碼
來源:易賢網(wǎng) 閱讀:966 次 日期:2016-06-17 10:10:23
溫馨提示:易賢網(wǎng)小編為您整理了“vbs 十六進(jìn)制異或加密實現(xiàn)代碼”,方便廣大網(wǎng)友查閱!

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

代碼都封裝成函數(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

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

2025國考·省考課程試聽報名

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