vbs版的解密base64加密的脚本
程序员文章站
2022-07-04 20:53:49
复制代码 代码如下:function fdecode(sstringtodecode) 'this function will&n...
复制代码 代码如下:
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
vbs代码打包