From 080b88d43f6c8d4e03e72268e78e21d801418339 Mon Sep 17 00:00:00 2001 From: KF7EEL Date: Wed, 12 May 2021 13:17:20 -0700 Subject: [PATCH] add option to shorten passphrase --- config.py | 1 + hblink-SAMPLE.cfg | 2 ++ user_managment/app.py | 6 +++++- user_managment/config-SAMPLE.py | 2 ++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/config.py b/config.py index ca0aafe..ec1b6f1 100755 --- a/config.py +++ b/config.py @@ -159,6 +159,7 @@ def build_config(_config_file): 'URL': config.get(section, 'URL'), 'APPEND_INT': config.getint(section, 'APPEND_INT'), 'SHARED_SECRET': config.get(section, 'SHARED_SECRET'), + 'SHORTEN_PASSPHRASE': config.getboolean(section, 'SHORTEN_PASSPHRASE'), }) diff --git a/hblink-SAMPLE.cfg b/hblink-SAMPLE.cfg index 6421572..28e5ee6 100755 --- a/hblink-SAMPLE.cfg +++ b/hblink-SAMPLE.cfg @@ -148,6 +148,8 @@ URL: http://localhost:8080/auth APPEND_INT: 1 # Secret used to authenticate with user managment server, before checking if user login is approved SHARED_SECRET: test +# Shorten passphrases to 8 characters +SHORTEN_PASSPHRASE: False # MASTER INSTANCES - DUPLICATE SECTION FOR MULTIPLE MASTERS diff --git a/user_managment/app.py b/user_managment/app.py index c3a5039..86eb94b 100644 --- a/user_managment/app.py +++ b/user_managment/app.py @@ -30,7 +30,11 @@ script_links = {} def gen_passphrase(dmr_id): _new_peer_id = bytes_4(int(str(dmr_id)[:7])) calc_passphrase = base64.b64encode(bytes.fromhex(str(hex(libscrc.ccitt((_new_peer_id) + append_int.to_bytes(2, 'big') + bytes.fromhex(str(hex(libscrc.posix((_new_peer_id) + append_int.to_bytes(2, 'big'))))[2:].zfill(8)))))[2:].zfill(4)) + (_new_peer_id) + append_int.to_bytes(2, 'big') + bytes.fromhex(str(hex(libscrc.posix((_new_peer_id) + append_int.to_bytes(2, 'big'))))[2:].zfill(8))) - return str(calc_passphrase)[2:-1] + print(calc_passphrase) + if use_short_passphrase == True: + return str(calc_passphrase)[-9:-1] + elif use_short_passphrase ==False: + return str(calc_passphrase)[2:-1] def get_ids(callsign): try: diff --git a/user_managment/config-SAMPLE.py b/user_managment/config-SAMPLE.py index fb2244b..ab1cfa7 100644 --- a/user_managment/config-SAMPLE.py +++ b/user_managment/config-SAMPLE.py @@ -8,6 +8,8 @@ db_location = 'sqlite:///./users.db' # Legacy passphrase used in hblink.cfg legacy_passphrase = 'passw0rd' +# Trim passphrases to 8 characters +use_short_passphrase = False # Title of the Dashboard title = 'MMDVM User Portal'