From 244e2b1ff16071f0b00ca35b43a03e221b9a75fd Mon Sep 17 00:00:00 2001
From: schroeder5 <s.schroeder@fz-juelich.de>
Date: Tue, 27 Feb 2024 10:44:10 +0000
Subject: [PATCH] tool to create a password for a GUI user

---
 utils/create_user_password.py | 42 +++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 utils/create_user_password.py

diff --git a/utils/create_user_password.py b/utils/create_user_password.py
new file mode 100644
index 0000000..19435d5
--- /dev/null
+++ b/utils/create_user_password.py
@@ -0,0 +1,42 @@
+"""
+create an encrypted password for a DestinE AQ (Core) User
+=========================================================
+
+   - encrypt a given password with the Fernet key used in the DestinE AQ GUI
+
+   author:
+   s.schroeder@fz-juelich.de
+
+   date: 2024/02/27
+
+   call:
+   python create_user_password.py aWonderfulPassword
+"""
+
+__author__ = "Sabine Schroeder"
+__version__ = "0.9"
+__maintainer__ = "Sabine Schroeder"
+__email__ = "s.schroeder@fz-juelich.de"
+
+
+from cryptography.fernet import Fernet
+from deployment_settings import KEY
+import argparse
+
+
+if __name__ == "__main__":
+    # get command line arguments
+    # instantiate the parser
+    parser = argparse.ArgumentParser(description='This app encrypts a given password with the Fernet key used in the DestinE AQ GUI')
+
+    # add arguments (required positional arguments)
+    parser.add_argument('password', type=str, help='password to be encrypted')
+
+    # parse the args
+    args = parser.parse_args()
+
+    # assign command line arguments
+    password = args.password
+
+    fernet = Fernet(KEY)
+    print(fernet.encrypt(password.encode()))
-- 
GitLab