vbs 十六进制异或加密实现代码
来源:易贤网 阅读:962 次 日期:2016-06-17 10:10:23
温馨提示:易贤网小编为您整理了“vbs 十六进制异或加密实现代码”,方便广大网友查阅!

文件不要过大,最好不要超过 100 kb,密钥不要用数字,不想改了。理论上支持任何二进制文件格式

代码都封装成函数了,方便调用:

代码如下:

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 十六进制异或加密实现代码
由于各方面情况的不断调整与变化,易贤网提供的所有考试信息和咨询回复仅供参考,敬请考生以权威部门公布的正式信息和咨询为准!

2025国考·省考课程试听报名

  • 报班类型
  • 姓名
  • 手机号
  • 验证码
关于我们 | 联系我们 | 人才招聘 | 网站声明 | 网站帮助 | 非正式的简要咨询 | 简要咨询须知 | 加入群交流 | 手机站点 | 投诉建议
工业和信息化部备案号:滇ICP备2023014141号-1 云南省教育厅备案号:云教ICP备0901021 滇公网安备53010202001879号 人力资源服务许可证:(云)人服证字(2023)第0102001523号
云南网警备案专用图标
联系电话:0871-65099533/13759567129 获取招聘考试信息及咨询关注公众号:hfpxwx
咨询QQ:526150442(9:00—18:00)版权所有:易贤网
云南网警报警专用图标