vbs base64 解密脚本代码
程序员文章站
2022-07-04 20:48:41
复制代码 代码如下:function fdecode(sstringtodecode) 'this function will decode a base64 encode...
复制代码 代码如下:
function fdecode(sstringtodecode)
'this function will decode a base64 encoded string and returns the decoded string.
'this becomes usefull when attempting to hide passwords from prying eyes.
const charlist = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789+/"
dim idatalength, soutputstring, igroupinitialcharacter
sstringtodecode = replace(replace(replace(sstringtodecode, vbcrlf, ""), vbtab, ""), " ", "")
idatalength = len(sstringtodecode)
if idatalength mod 4 <> 0 then
fdecode = "bad string passed to fdecode() function."
exit function
end if
for igroupinitialcharacter = 1 to idatalength step 4
dim idatabytecount, icharactercounter, scharacter, idata, igroup, spreliminaryoutstring
idatabytecount = 3
igroup = 0
for icharactercounter = 0 to 3
scharacter = mid(sstringtodecode, igroupinitialcharacter + icharactercounter, 1)
if scharacter = "=" then
idatabytecount = idatabytecount - 1
idata = 0
else
idata = instr(1, charlist, scharacter, 0) - 1
if idata = -1 then
fdecode = "bad string passed to fdecode() function."
exit function
end if
end if
igroup = 64 * igroup + idata
next
igroup = hex(igroup)
igroup = string(6 - len(igroup), "0") & igroup
spreliminaryoutstring = chr(cbyte("&h" & mid(igroup, 1, 2))) & chr(cbyte("&h" & mid(igroup, 3, 2))) & chr(cbyte("&h" & mid(igroup, 5, 2)))
soutputstring = soutputstring & left(spreliminaryoutstring, idatabytecount)
next
fdecode = soutputstring
end function
base64 测试代码:
复制代码 代码如下:
function fdecode(sstringtodecode)
'this function will decode a base64 encoded string and returns the decoded string.
'this becomes usefull when attempting to hide passwords from prying eyes.
const charlist = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789+/"
dim idatalength, soutputstring, igroupinitialcharacter
sstringtodecode = replace(replace(replace(sstringtodecode, vbcrlf, ""), vbtab, ""), " ", "")
idatalength = len(sstringtodecode)
if idatalength mod 4 <> 0 then
fdecode = "bad string passed to fdecode() function."
exit function
end if
for igroupinitialcharacter = 1 to idatalength step 4
dim idatabytecount, icharactercounter, scharacter, idata, igroup, spreliminaryoutstring
idatabytecount = 3
igroup = 0
for icharactercounter = 0 to 3
scharacter = mid(sstringtodecode, igroupinitialcharacter + icharactercounter, 1)
if scharacter = "=" then
idatabytecount = idatabytecount - 1
idata = 0
else
idata = instr(1, charlist, scharacter, 0) - 1
if idata = -1 then
fdecode = "bad string passed to fdecode() function."
exit function
end if
end if
igroup = 64 * igroup + idata
next
igroup = hex(igroup)
igroup = string(6 - len(igroup), "0") & igroup
spreliminaryoutstring = chr(cbyte("&h" & mid(igroup, 1, 2))) & chr(cbyte("&h" & mid(igroup, 3, 2))) & chr(cbyte("&h" & mid(igroup, 5, 2)))
soutputstring = soutputstring & left(spreliminaryoutstring, idatabytecount)
next
fdecode = soutputstring
end function
msgbox fdecode("d3d3lmpinteubmv0")
需要测试加密的代码的朋友可以访问