Copy Code code as follows:
Function Fdecode (Sstringtodecode)
' This function would decode a BASE64 encoded string and returns the decoded string.
' This becomes usefull if 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 = 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)) &A mp CHR (CByte ("&h" & Mid (Igroup, 5, 2))
soutputstring = soutputstring & Left (spreliminaryoutstring, Idatabytecount)
Next
Fdecode = soutputstring
End Function
Base64 Test Code:
Copy Code code as follows:
Function Fdecode (Sstringtodecode)
' This function would decode a BASE64 encoded string and returns the decoded string.
' This becomes usefull if 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 = 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)) &A mp 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 encrypted code can access the Http://www.jb51.net/tools/base64.htm