Added base64 encoding and decoding
This commit is contained in:
parent
434d36c76d
commit
160696871f
2 changed files with 62 additions and 0 deletions
19
btoa.bm
Normal file
19
btoa.bm
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
Function btoa$ (s As String)
|
||||
Const B64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
|
||||
Dim c1 As _Byte
|
||||
Dim c2 As _Byte
|
||||
Dim c3 As _Byte
|
||||
Dim c4 As _Byte
|
||||
Dim i As Long
|
||||
Dim As String Buffer
|
||||
For i = 1 To Len(s) Step 4
|
||||
c1 = InStr(B64, Mid$(s, i + 0, 1)) - 1
|
||||
c2 = InStr(B64, Mid$(s, i + 1, 1)) - 1
|
||||
c3 = InStr(B64, Mid$(s, i + 2, 1)) - 1
|
||||
c4 = InStr(B64, Mid$(s, i + 3, 1)) - 1
|
||||
If c2 > -1 Then Buffer = Buffer + Chr$(((c1 * 4 + c2 \ 16) And 255))
|
||||
If c3 > -1 Then Buffer = Buffer + Chr$(((c2 * 16 + c3 \ 4) And 255))
|
||||
If c4 > -1 Then Buffer = Buffer + Chr$(((c3 * 64 + c4) And 255))
|
||||
Next i
|
||||
btoa$ = Buffer
|
||||
End Function
|
||||
Loading…
Add table
Add a link
Reference in a new issue