Merge branch 'main' into avm99963-monorail

Merged commit 34d8229ae2b51fb1a15bd208e6fe6185c94f6266

GitOrigin-RevId: 7ee0917f93a577e475f8e09526dd144d245593f4
diff --git a/tracker/attachment_helpers.py b/tracker/attachment_helpers.py
index 9ed9a7c..8086182 100644
--- a/tracker/attachment_helpers.py
+++ b/tracker/attachment_helpers.py
@@ -1,7 +1,6 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file or at
-# https://developers.google.com/open-source/licenses/bsd
+# Copyright 2016 The Chromium Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
 
 """Functions to help display attachments and compute quotas."""
 from __future__ import print_function
@@ -9,8 +8,9 @@
 from __future__ import absolute_import
 
 import base64
+import hashlib
 import hmac
-import logging
+import six
 
 from framework import urls
 from services import secrets_svc
@@ -71,9 +71,9 @@
 
 def SignAttachmentID(aid):
   """One-way hash of attachment ID to make it harder for people to scan."""
-  digester = hmac.new(secrets_svc.GetXSRFKey())
-  digester.update(str(aid))
-  return base64.urlsafe_b64encode(digester.digest())
+  digester = hmac.new(secrets_svc.GetXSRFKey(), digestmod=hashlib.md5)
+  digester.update(six.ensure_binary(str(aid)))
+  return six.ensure_str(base64.urlsafe_b64encode(digester.digest()))
 
 
 def GetDownloadURL(attachment_id):