Function Base64Decode( ByVal InBuff As String, ByVal B64_Alpha As String) As String
If B64_Alpha="" Then
B64_Alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
End If
B64_Alpha="=" & B64_Alpha
Local w1,w2,w3,w4,n,b As Long
Local retry As String
Local By() As Byte
b = -1
For n = 1 To Len(InBuff) Step 4
w1 = Instr(B64_Alpha, Mid$(InBuff, n, 1)) - 2
w2 = Instr(B64_Alpha, Mid$(InBuff, n + 1, 1)) - 2
w3 = Instr(B64_Alpha, Mid$(InBuff, n + 2, 1)) - 2
w4 = Instr(B64_Alpha, Mid$(InBuff, n + 3, 1)) - 2
If w2 >= 0 Then
b = b + 1: ReDim Preserve By(b)
By(b) = (w1 * 4 + Int(w2 / 16)) And 255
End If
If w3 >= 0 Then
b = b + 1: ReDim Preserve By(b)
By(b) = (w2 * 16 + Int(w3 / 4)) And 255
End If
If w4 >= 0 Then
b = b + 1: ReDim Preserve By(b)
By(b) = (w3 * 64 + w4) And 255
End If
Next
retry=Space$(UBound(by)+1)
FF_MemCopy VarPtr(by(0)),StrPtr(retry) ,UBound(by)+1
Function = retry 'return the decoded string
End Function