MCPcopy Create free account
hub / github.com/6dylan6/jdm / base64Encode

Function base64Encode

signapi.py:117–132  ·  view source on GitHub ↗
(string)

Source from the content-addressed store, hash-verified

115
116
117def base64Encode(string):
118 oldBin = ""
119 tempStr = []
120 result = ""
121 base64_list = 'KLMNOPQRSTABCDEFGHIJUVWXYZabcdopqrstuvwxefghijklmnyz0123456789+/'
122 for ch in string:
123 oldBin += "{:08}".format(int(str(bin(ord(ch))).replace("0b", "")))
124 for i in range(0, len(oldBin), 6):
125 tempStr.append("{:<06}".format(oldBin[i:i + 6]))
126 for item in tempStr:
127 result = result + base64_list[int(item, 2)]
128 if len(result) % 4 == 2:
129 result += "=="
130 elif len(result) % 4 == 3:
131 result += "="
132 return result
133
134
135def base64Decode(string):

Callers 1

taskFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected