CopyCode The Code is as follows: 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 (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 test code:Copy code The Code is as follows: 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 (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 ")
Friends who need to test the encrypted code can access the http://www.jb51.net/tools/base64.htm