MCPcopy Index your code
hub / github.com/sqlmapproject/sqlmap / decodeBase64

Function decodeBase64

lib/core/convert.py:199–238  ·  view source on GitHub ↗

Returns a decoded representation of provided Base64 value >>> decodeBase64("MTIz") == b"123" True >>> decodeBase64("MTIz", binary=False) '123' >>> decodeBase64("A-B_CDE") == decodeBase64("A+B/CDE") True >>> decodeBase64(b"MTIzNA") == b"1234" True >>> decodeB

(value, binary=True, encoding=None)

Source from the content-addressed store, hash-verified

197 return retVal
198
199def decodeBase64(value, binary=True, encoding=None):
200 """
201 Returns a decoded representation of provided Base64 value
202
203 >>> decodeBase64("MTIz") == b"123"
204 True
205 >>> decodeBase64("MTIz", binary=False)
206 '123'
207 >>> decodeBase64("A-B_CDE") == decodeBase64("A+B/CDE")
208 True
209 >>> decodeBase64(b"MTIzNA") == b"1234"
210 True
211 >>> decodeBase64("MTIzNA") == b"1234"
212 True
213 >>> decodeBase64("MTIzNA==") == b"1234"
214 True
215 """
216
217 if value is None:
218 return None
219
220 padding = b'=' if isinstance(value, bytes) else '='
221
222 # Reference: https://stackoverflow.com/a/49459036
223 if not value.endswith(padding):
224 value += 3 * padding
225
226 # Reference: https://en.wikipedia.org/wiki/Base64#URL_applications
227 # Reference: https://perldoc.perl.org/MIME/Base64.html
228 if isinstance(value, bytes):
229 value = value.replace(b'-', b'+').replace(b'_', b'/')
230 else:
231 value = value.replace('-', '+').replace('_', '/')
232
233 retVal = base64.b64decode(value)
234
235 if not binary:
236 retVal = getText(retVal, encoding)
237
238 return retVal
239
240def encodeBase64(value, binary=True, encoding=None, padding=True, safe=False):
241 """

Callers 8

dictionaryAttackFunction · 0.90
check_authenticationFunction · 0.90
initTargetEnvFunction · 0.90
paramToDictFunction · 0.90
createGithubIssueFunction · 0.90
_parseBurpLogFunction · 0.90
_oneShotUnionUseFunction · 0.90
base64unpickleFunction · 0.85

Calls 2

getTextFunction · 0.85
replaceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…