From ba178d0dfe3f2e1ab623d7fa495fc0c76ab7c28c Mon Sep 17 00:00:00 2001 From: Ronit Jain Date: Tue, 14 Nov 2023 03:16:50 +0530 Subject: [PATCH] Normalize Encryption File Read Line Endings (#379) * normalize line ending to that of terminal * preserve line endling when reading * preserve line ending when reading key content --- lean/components/util/encryption_helper.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lean/components/util/encryption_helper.py b/lean/components/util/encryption_helper.py index 8a50e3b8..b4aa6198 100644 --- a/lean/components/util/encryption_helper.py +++ b/lean/components/util/encryption_helper.py @@ -49,7 +49,7 @@ def get_project_key(project_key_path: Path, organization_id: str) -> str: :param project_key_path: The path to the project key file :return: The project key """ - with open(project_key_path, 'r') as f: + with open(project_key_path, 'r', encoding='utf-8', newline='') as f: content = f.read() key_for_aes = _get_fixed_length_key_from_user_full_length_key(content, organization_id.encode('utf-8')) return key_for_aes @@ -60,7 +60,7 @@ def get_project_key_hash(project_key_path: Path): :param project_key_path: The path to the project key file :return: The project iv """ - with open(project_key_path, 'r', encoding='utf-8') as f: + with open(project_key_path, 'r', encoding='utf-8', newline='') as f: content = f.read() return calculate_md5(content)