bsp; out = out + "=="
base64encode = out
Exit Function
End If
c2 = Asc(Mid(str, i + 1, 1))
i = i + 1
If (i = len1) Then
out = out + Mid(base64EncodeChars, c1 \ 4 + 1, 1)
out = out + Mid(base64EncodeChars, (((c1 And 3) * 16) Or ((c2 And 240) \ 16)) + 1, 1)
out = out + Mid(base64EncodeChars, (c2 And 15) * 4 + 1, 1)
out = out + "="
base64encode = out
Exit Function
End If
c3 = Asc(Mid(str, i + 1, 1))
i = i + 1
out = out + Mid(base64EncodeChars, c1 \ 4 + 1, 1)
out = out + Mid(base64EncodeChars, (((c1 And 3) * 16) Or ((c2 And 240) \ 16)) + 1, 1)
out = out + Mid(base64EncodeChars, (((c2 And 15) * 4) Or ((c3 And 192) \ 64)) + 1, 1)
out = out + Mid(base64EncodeChars, (c3 And 63) + 1, 1)
Wend
base64encode = out
End Function
Function base64decode(str As String) As String
For i = 0 To 127
base64DecodeChars(i) = -1
Next
base64DecodeChars(43) = 62
base64DecodeChars(47) = 63
For i = 48 To 57
base64DecodeChars(i) = i + 4
Next
For i = 65 To 90
base64DecodeChars(i) = i - 65
Next
For i = 97 To 122
base64DecodeChars(i) = i - 71
Next
Dim c1, c2, c3, c4
Dim len1, out
len1 = Len(str)
i = 0
out = ""
While (i < len1)
Do
&nbs