prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  ETag checksum fails on FIPS-enabled systems when using MD5
  ### Checklist
  
  <!-- Please make sure you check all these items before submitting your bug report. -->
  
  - [x] The bug is reproducible against the latest release and/or `master`.
  - [x] There are no similar issues or pull requests to fix it yet.
  
  ### Describe the bug
  
  The ETag checksum fails when using MD5. This is causing Starlette to not work at all under Red Hat Enterprise Linux when FIPS mode is enabled.
  
  ### Debugging material
  
  Here's the exception that's thrown:
  
  ```
  INFO:     10.42.1.7:34422 - "GET /app/static/foo.html HTTP/1.1" 500 Internal Server Error
  ERROR:    Exception in ASGI application
  Traceback (most recent call last):
    File "/usr/local/lib/python3.8/site-packages/uvicorn/protocols/http/h11_impl.py", line 373, in run_asgi
      result = await app(self.scope, self.receive, self.send)
    File "/usr/local/lib/python3.8/site-packages/uvicorn/middleware/proxy_headers.py", line 75, in __call__
      return await self.app(scope, receive, send)
    File "/usr/local/lib/python3.8/site-packages/fastapi/applications.py", line 208, in __call__
      await super().__call__(scope, receive, send)
    File "/usr/local/lib/python3.8/site-packages/starlette/applications.py", line 112, in __call__
      await self.middleware_stack(scope, receive, send)
    File "/usr/local/lib/python3.8/site-packages/starlette/middleware/errors.py", line 181, in __call__
      raise exc
    File "/usr/local/lib/python3.8/site-packages/starlette/middleware/errors.py", line 159, in __call__
      await self.app(scope, receive, _send)
    File "/usr/local/lib/python3.8/site-packages/starlette/exceptions.py", line 82, in __call__
      raise exc
    File "/usr/local/lib/python3.8/site-packages/starlette/exceptions.py", line 71, in __call__
      await self.app(scope, receive, sender)
    File "/usr/local/lib/python3.8/site-packages/starlette/routing.py", line 656, in __call__
      await route.handle(scope, receive, send)
    File "/usr/local/lib/python3.8/site-packages/starlette/routing.py", line 408, in handle
      await self.app(scope, receive, send)
    File "/usr/local/lib/python3.8/site-packages/starlette/staticfiles.py", line 97, in __call__
      response = await self.get_response(path, scope)
    File "/usr/local/lib/python3.8/site-packages/starlette/staticfiles.py", line 118, in get_response
      return self.file_response(full_path, stat_result, scope)
    File "/usr/local/lib/python3.8/site-packages/starlette/staticfiles.py", line 173, in file_response
      response = FileResponse(
    File "/usr/local/lib/python3.8/site-packages/starlette/responses.py", line 267, in __init__
      self.set_stat_headers(stat_result)
    File "/usr/local/lib/python3.8/site-packages/starlette/responses.py", line 273, in set_stat_headers
      etag = hashlib.md5(etag_base.encode()).hexdigest()
  ValueError: [digital envelope routines: EVP_DigestInit_ex] disabled for FIPS
  ```
  
  ### Environment
  
  - OS: Red Hat Enterprise Linux 8 in FIPS mode
  - Python version: 3.8.8
  - Starlette version: 0.16.0
  
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `starlette/_compat.py`
  Content:
  ```
  1 import hashlib
  2 
  3 # Compat wrapper to always include the `usedforsecurity=...` parameter,
  4 # which is only added from Python 3.9 onwards.
  5 # We use this flag to indicate that we use `md5` hashes only for non-security
  6 # cases (our ETag checksums).
  7 # If we don't indicate that we're using MD5 for non-security related reasons,
  8 # then attempting to use this function will raise an error when used
  9 # environments which enable a strict "FIPs mode".
  10 #
  11 # See issue: https://github.com/encode/starlette/issues/1365
  12 try:
  13 
  14     hashlib.md5(b"data", usedforsecurity=True)  # type: ignore[call-arg]
  15 
  16     def md5_hexdigest(
  17         data: bytes, *, usedforsecurity: bool = True
  18     ) -> str:  # pragma: no cover
  19         return hashlib.md5(  # type: ignore[call-arg]
  20             data, usedforsecurity=usedforsecurity
  21         ).hexdigest()
  22 
  23 except TypeError:  # pragma: no cover
  24 
  25     def md5_hexdigest(data: bytes, *, usedforsecurity: bool = True) -> str:
  26         return hashlib.md5(data).hexdigest()
  27
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/starlette/_compat.py b/starlette/_compat.py
  --- a/starlette/_compat.py
  +++ b/starlette/_compat.py
  @@ -11,7 +11,10 @@
   # See issue: https://github.com/encode/starlette/issues/1365
   try:
   
  -    hashlib.md5(b"data", usedforsecurity=True)  # type: ignore[call-arg]
  +    # check if the Python version supports the parameter
  +    # using usedforsecurity=False to avoid an exception on FIPS systems
  +    # that reject usedforsecurity=True
  +    hashlib.md5(b"data", usedforsecurity=False)  # type: ignore[call-arg]
   
       def md5_hexdigest(
           data: bytes, *, usedforsecurity: bool = True
  
verification_info: {"golden_diff": "diff --git a/starlette/_compat.py b/starlette/_compat.py\n--- a/starlette/_compat.py\n+++ b/starlette/_compat.py\n@@ -11,7 +11,10 @@\n # See issue: https://github.com/encode/starlette/issues/1365\n try:\n \n-    hashlib.md5(b\"data\", usedforsecurity=True)  # type: ignore[call-arg]\n+    # check if the Python version supports the parameter\n+    # using usedforsecurity=False to avoid an exception on FIPS systems\n+    # that reject usedforsecurity=True\n+    hashlib.md5(b\"data\", usedforsecurity=False)  # type: ignore[call-arg]\n \n     def md5_hexdigest(\n         data: bytes, *, usedforsecurity: bool = True\n", "issue": "ETag checksum fails on FIPS-enabled systems when using MD5\n### Checklist\r\n\r\n<!-- Please make sure you check all these items before submitting your bug report. -->\r\n\r\n- [x] The bug is reproducible against the latest release and/or `master`.\r\n- [x] There are no similar issues or pull requests to fix it yet.\r\n\r\n### Describe the bug\r\n\r\nThe ETag checksum fails when using MD5. This is causing Starlette to not work at all under Red Hat Enterprise Linux when FIPS mode is enabled.\r\n\r\n### Debugging material\r\n\r\nHere's the exception that's thrown:\r\n\r\n```\r\nINFO:     10.42.1.7:34422 - \"GET /app/static/foo.html HTTP/1.1\" 500 Internal Server Error\r\nERROR:    Exception in ASGI application\r\nTraceback (most recent call last):\r\n  File \"/usr/local/lib/python3.8/site-packages/uvicorn/protocols/http/h11_impl.py\", line 373, in run_asgi\r\n    result = await app(self.scope, self.receive, self.send)\r\n  File \"/usr/local/lib/python3.8/site-packages/uvicorn/middleware/proxy_headers.py\", line 75, in __call__\r\n    return await self.app(scope, receive, send)\r\n  File \"/usr/local/lib/python3.8/site-packages/fastapi/applications.py\", line 208, in __call__\r\n    await super().__call__(scope, receive, send)\r\n  File \"/usr/local/lib/python3.8/site-packages/starlette/applications.py\", line 112, in __call__\r\n    await self.middleware_stack(scope, receive, send)\r\n  File \"/usr/local/lib/python3.8/site-packages/starlette/middleware/errors.py\", line 181, in __call__\r\n    raise exc\r\n  File \"/usr/local/lib/python3.8/site-packages/starlette/middleware/errors.py\", line 159, in __call__\r\n    await self.app(scope, receive, _send)\r\n  File \"/usr/local/lib/python3.8/site-packages/starlette/exceptions.py\", line 82, in __call__\r\n    raise exc\r\n  File \"/usr/local/lib/python3.8/site-packages/starlette/exceptions.py\", line 71, in __call__\r\n    await self.app(scope, receive, sender)\r\n  File \"/usr/local/lib/python3.8/site-packages/starlette/routing.py\", line 656, in __call__\r\n    await route.handle(scope, receive, send)\r\n  File \"/usr/local/lib/python3.8/site-packages/starlette/routing.py\", line 408, in handle\r\n    await self.app(scope, receive, send)\r\n  File \"/usr/local/lib/python3.8/site-packages/starlette/staticfiles.py\", line 97, in __call__\r\n    response = await self.get_response(path, scope)\r\n  File \"/usr/local/lib/python3.8/site-packages/starlette/staticfiles.py\", line 118, in get_response\r\n    return self.file_response(full_path, stat_result, scope)\r\n  File \"/usr/local/lib/python3.8/site-packages/starlette/staticfiles.py\", line 173, in file_response\r\n    response = FileResponse(\r\n  File \"/usr/local/lib/python3.8/site-packages/starlette/responses.py\", line 267, in __init__\r\n    self.set_stat_headers(stat_result)\r\n  File \"/usr/local/lib/python3.8/site-packages/starlette/responses.py\", line 273, in set_stat_headers\r\n    etag = hashlib.md5(etag_base.encode()).hexdigest()\r\nValueError: [digital envelope routines: EVP_DigestInit_ex] disabled for FIPS\r\n```\r\n\r\n### Environment\r\n\r\n- OS: Red Hat Enterprise Linux 8 in FIPS mode\r\n- Python version: 3.8.8\r\n- Starlette version: 0.16.0\r\n\r\n\n", "before_files": [{"content": "import hashlib\n\n# Compat wrapper to always include the `usedforsecurity=...` parameter,\n# which is only added from Python 3.9 onwards.\n# We use this flag to indicate that we use `md5` hashes only for non-security\n# cases (our ETag checksums).\n# If we don't indicate that we're using MD5 for non-security related reasons,\n# then attempting to use this function will raise an error when used\n# environments which enable a strict \"FIPs mode\".\n#\n# See issue: https://github.com/encode/starlette/issues/1365\ntry:\n\n    hashlib.md5(b\"data\", usedforsecurity=True)  # type: ignore[call-arg]\n\n    def md5_hexdigest(\n        data: bytes, *, usedforsecurity: bool = True\n    ) -> str:  # pragma: no cover\n        return hashlib.md5(  # type: ignore[call-arg]\n            data, usedforsecurity=usedforsecurity\n        ).hexdigest()\n\nexcept TypeError:  # pragma: no cover\n\n    def md5_hexdigest(data: bytes, *, usedforsecurity: bool = True) -> str:\n        return hashlib.md5(data).hexdigest()\n", "path": "starlette/_compat.py"}], "after_files": [{"content": "import hashlib\n\n# Compat wrapper to always include the `usedforsecurity=...` parameter,\n# which is only added from Python 3.9 onwards.\n# We use this flag to indicate that we use `md5` hashes only for non-security\n# cases (our ETag checksums).\n# If we don't indicate that we're using MD5 for non-security related reasons,\n# then attempting to use this function will raise an error when used\n# environments which enable a strict \"FIPs mode\".\n#\n# See issue: https://github.com/encode/starlette/issues/1365\ntry:\n\n    # check if the Python version supports the parameter\n    # using usedforsecurity=False to avoid an exception on FIPS systems\n    # that reject usedforsecurity=True\n    hashlib.md5(b\"data\", usedforsecurity=False)  # type: ignore[call-arg]\n\n    def md5_hexdigest(\n        data: bytes, *, usedforsecurity: bool = True\n    ) -> str:  # pragma: no cover\n        return hashlib.md5(  # type: ignore[call-arg]\n            data, usedforsecurity=usedforsecurity\n        ).hexdigest()\n\nexcept TypeError:  # pragma: no cover\n\n    def md5_hexdigest(data: bytes, *, usedforsecurity: bool = True) -> str:\n        return hashlib.md5(data).hexdigest()\n", "path": "starlette/_compat.py"}]}