mirror of
https://github.com/zulip/zulip.git
synced 2025-10-28 10:33:54 +00:00
python: Replace binascii with bytes.hex to skip some decode operations.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
aaa7b766d8
commit
18d0e4664c
@@ -1,4 +1,3 @@
|
||||
import binascii
|
||||
import hashlib
|
||||
import hmac
|
||||
|
||||
@@ -9,8 +8,7 @@ def generate_camo_url(url: str) -> str:
|
||||
encoded_url = url.encode("utf-8")
|
||||
encoded_camo_key = settings.CAMO_KEY.encode("utf-8")
|
||||
digest = hmac.new(encoded_camo_key, encoded_url, hashlib.sha1).hexdigest()
|
||||
hex_encoded_url = binascii.b2a_hex(encoded_url)
|
||||
return "{}/{}".format(digest, hex_encoded_url.decode("utf-8"))
|
||||
return "{}/{}".format(digest, encoded_url.hex())
|
||||
|
||||
# Encodes the provided URL using the same algorithm used by the camo
|
||||
# caching https image proxy
|
||||
|
||||
Reference in New Issue
Block a user