mirror of
https://github.com/zulip/zulip.git
synced 2025-11-13 18:36:36 +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,5 +1,4 @@
|
||||
import base64
|
||||
import binascii
|
||||
import logging
|
||||
import re
|
||||
import time
|
||||
@@ -45,10 +44,10 @@ DeviceToken = Union[PushDeviceToken, "RemotePushDeviceToken"]
|
||||
|
||||
# We store the token as b64, but apns-client wants hex strings
|
||||
def b64_to_hex(data: str) -> str:
|
||||
return binascii.hexlify(base64.b64decode(data)).decode('utf-8')
|
||||
return base64.b64decode(data).hex()
|
||||
|
||||
def hex_to_b64(data: str) -> str:
|
||||
return base64.b64encode(binascii.unhexlify(data)).decode()
|
||||
return base64.b64encode(bytes.fromhex(data)).decode()
|
||||
|
||||
#
|
||||
# Sending to APNs, for iOS
|
||||
|
||||
Reference in New Issue
Block a user