Every line of 'python base64 decode' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
48 def base64_decode(data): 49 # Base64 returns decoded byte string, decode to convert to UTF8 string 50 return base64.b64decode(data).decode('utf8')
156 def base64_url_decode(data): 157 data = data.encode('ascii') 158 data += '=' * (4 - (len(data) % 4)) 159 return base64.urlsafe_b64decode(data)
23 def base64_decode(s, convert_eols=None): 24 """Decode a raw base64 string. 25 26 If convert_eols is set to a string value, all canonical email linefeeds, 27 e.g. "\\r\\n", in the decoded text will be converted to the value of 28 convert_eols. os.linesep is a good choice for convert_eols if you are 29 decoding a text attachment. 30 31 This function does not parse a full MIME header value encoded with 32 base64 (like =?iso-8895-1?b?bmloISBuaWgh?=) -- please use the high 33 level email.Header class for that functionality. 34 35 Taken from 'email' module 36 """ 37 if not s: 38 return s 39 40 dec = a2b_base64(s) 41 if convert_eols: 42 return dec.replace(CRLF, convert_eols) 43 return dec
92 def urlsafe_b64decode(s): 93 """Decode bytes using the URL- and filesystem-safe Base64 alphabet. 94 95 Argument ``s`` is a :term:`bytes-like object` or ASCII string to 96 decode. 97 98 The result is returned as a :class:`bytes` object. 99 100 A :exc:`binascii.Error` is raised if the input is incorrectly padded. 101 102 Characters that are not in the URL-safe base-64 alphabet, and are not 103 a plus '+' or slash '/', are discarded prior to the padding check. 104 105 The alphabet uses '-' instead of '+' and '_' instead of '/'. 106 """ 107 return b64decode(s, b'-_')
51 def b64decode(data: str) -> bytes: 52 # Apply missing padding 53 missing_padding = len(data) % 4 54 if missing_padding: 55 data += "=" * (4 - missing_padding) 56 return base64.b64decode(data)
101 def decode(self, s): 102 return b64decode(s)
227 def base64_decode_string(*args, **kwargs): 228 return base64.decodestring(*args, **kwargs)
102 def decode(string): 103 """Decode a raw base64 string, returning a bytes object. 104 105 This function does not parse a full MIME header value encoded with 106 base64 (like =?iso-8895-1?b?bmloISBuaWgh?=) -- please use the high 107 level email.Header class for that functionality. 108 """ 109 if not string: 110 return bytes() 111 elif isinstance(string, str): 112 return a2b_base64(string.encode('raw-unicode-escape')) 113 else: 114 return a2b_base64(string)
27 def b64decode(s): 28 return base64.b64decode(str_to_bytes(s))
106 def urlsafe_base64_decode(s): 107 assert isinstance(s, str) 108 try: 109 return base64.urlsafe_b64decode(s.ljust(len(s) + len(s) % 4, '=')) 110 except (LookupError, BinasciiError), e: 111 raise ValueError(e)