Rev 4256 | Blame | Compare with Previous | Last modification | View Log | RSS feed
'=====================================================' Base64Encode' Used in http Basic Authentication'' ripped from: 'http://www.pstruh.cz/tips/detpg_Base64Encode.htm' rfc1521' 2001 Antonin Foller, PSTRUH Software, http://pstruh.cz'=====================================================''------------ Functions -----------------------Function Base64Encode(inData)Const Base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"Dim sOut, I'For each group of 3 bytesFor I = 1 To Len(inData) Step 3Dim nGroup, pOut'Create one long from this 3 bytes.nGroup = &H10000 * Asc(Mid(inData, I, 1)) + _&H100 * MyASC(Mid(inData, I + 1, 1)) + _MyASC(Mid(inData, I + 2, 1))'Oct splits the long To 8 groups with 3 bitsnGroup = Oct(nGroup)'Add leading zerosnGroup = String(8 - Len(nGroup), "0") & nGroup'Convert To base64pOut = Mid(Base64, CLng("&o" & Mid(nGroup, 1, 2)) + 1, 1) + _Mid(Base64, CLng("&o" & Mid(nGroup, 3, 2)) + 1, 1) + _Mid(Base64, CLng("&o" & Mid(nGroup, 5, 2)) + 1, 1) + _Mid(Base64, CLng("&o" & Mid(nGroup, 7, 2)) + 1, 1)'Add the part To OutPut stringsOut = sOut + pOutNextSelect Case Len(inData) Mod 3Case 1: '8 bit finalsOut = Left(sOut, Len(sOut) - 2) + "=="Case 2: '16 bit finalsOut = Left(sOut, Len(sOut) - 1) + "="End SelectBase64Encode = sOutEnd FunctionFunction MyASC(OneChar)If OneChar = "" Then MyASC = 0 Else MyASC = Asc(OneChar)End Function'-- End of File