code: def b64d(b):
      
  
      cb = b.rstrip(b"=")  # shouldn't but there you are
  
      # Python's base64 functions ignore invalid characters, so we need to
      # check for them explicitly.
      if not _b64_re.match(cb):
          raise BadSyntax(cb, "base64-encoded data contains illegal characters")
  
      if cb == b:
          b = add_padding(b)
  
      return base64.urlsafe_b64decode(b)
docs: Decode some base64-encoded bytes.
  
      Raises BadSyntax if the string contains invalid characters or padding.
  
      :param b: bytes