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

Function encodeBase64

lib/core/convert.py:240–278  ·  view source on GitHub ↗

Returns a Base64 encoded representation of the provided value >>> encodeBase64(b"123") == b"MTIz" True >>> encodeBase64(u"1234", binary=False) 'MTIzNA==' >>> encodeBase64(u"1234", binary=False, padding=False) 'MTIzNA' >>> encodeBase64(decodeBase64("A-B_CDE"), binary

(value, binary=True, encoding=None, padding=True, safe=False)

Source from the content-addressed store, hash-verified

238 return retVal
239
240def encodeBase64(value, binary=True, encoding=None, padding=True, safe=False):
241 """
242 Returns a Base64 encoded representation of the provided value
243
244 >>> encodeBase64(b"123") == b"MTIz"
245 True
246 >>> encodeBase64(u"1234", binary=False)
247 'MTIzNA=='
248 >>> encodeBase64(u"1234", binary=False, padding=False)
249 'MTIzNA'
250 >>> encodeBase64(decodeBase64("A-B_CDE"), binary=False, safe=True)
251 'A-B_CDE'
252 """
253
254 if value is None:
255 return None
256
257 if isinstance(value, six.text_type):
258 value = value.encode(encoding or UNICODE_ENCODING)
259
260 retVal = base64.b64encode(value)
261
262 if not binary:
263 retVal = getText(retVal, encoding)
264
265 if safe:
266 padding = False
267
268 # Reference: https://en.wikipedia.org/wiki/Base64#URL_applications
269 # Reference: https://perldoc.perl.org/MIME/Base64.html
270 if isinstance(retVal, bytes):
271 retVal = retVal.replace(b'+', b'-').replace(b'/', b'_')
272 else:
273 retVal = retVal.replace('+', '-').replace('/', '_')
274
275 if not padding:
276 retVal = retVal.rstrip(b'=' if isinstance(retVal, bytes) else '=')
277
278 return retVal
279
280def getBytes(value, encoding=None, errors="strict", unsafe=True):
281 """

Callers 12

downloadFunction · 0.90
_clientFunction · 0.90
getPageMethod · 0.90
vulnTestFunction · 0.90
payloadMethod · 0.90
adjustLateValuesMethod · 0.90
fileContentEncodeMethod · 0.90
_stackedWriteFilePSMethod · 0.90
_stackedWriteFileVbsMethod · 0.90
tamperFunction · 0.90
base64pickleFunction · 0.85

Calls 2

getTextFunction · 0.85
replaceMethod · 0.45

Tested by 1

vulnTestFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…