mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-11-12 23:43:44 +08:00
7f3b68f0a8
Update Toyota ADAS messages and control interfaces with platform-specific safety tests. Co-authored-by: Dom <168790843+firestar5683@users.noreply.github.com> Co-authored-by: pharmacomaniac <blittle65@gmail.com>
18 lines
405 B
Python
18 lines
405 B
Python
"""Toyota SecOC key decoding; never include credentials in diagnostics."""
|
|
|
|
import re
|
|
|
|
|
|
def decode_key(value):
|
|
if isinstance(value, bytes):
|
|
try:
|
|
value = value.decode('ascii')
|
|
except UnicodeDecodeError:
|
|
return None
|
|
if type(value) is not str:
|
|
return None
|
|
value = value.strip()
|
|
if re.fullmatch(r'[0-9a-fA-F]{32}', value) is None:
|
|
return None
|
|
return bytes.fromhex(value)
|