From 10517ac94d781d462a1b6e84132043dbcf140f6c Mon Sep 17 00:00:00 2001 From: Douile <25043847+Douile@users.noreply.github.com> Date: Wed, 27 Jul 2022 15:12:23 +0100 Subject: [PATCH] Allow setting values from base64 values By prefixing a value with "base64:" e.g. ("base64:AQ==") it will now be decoded to raw bytes. This is useful when setting psk as that is often shown as base64. --- meshtastic/util.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/meshtastic/util.py b/meshtastic/util.py index 512be3e..73bc42a 100644 --- a/meshtastic/util.py +++ b/meshtastic/util.py @@ -64,6 +64,8 @@ def fromStr(valstr): elif valstr.startswith('0x'): # if needed convert to string with asBytes.decode('utf-8') val = bytes.fromhex(valstr[2:]) + elif valstr.startswith('base64:'): + val = base64.b64decode(valstr[7:]) elif valstr.lower() in {"t", "true", "yes"}: val = True elif valstr.lower() in {"f", "false", "no"}: