From 7e76aaa91559e8c0e4c8d5b0ad6e03729d5ff3be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Mar=C3=ADn?= Date: Fri, 5 Jul 2024 06:54:33 +0100 Subject: [PATCH 1/3] Update PyDelta.py Add uff-8 encoding to input file --- pydelta/PyDelta.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pydelta/PyDelta.py b/pydelta/PyDelta.py index 3a68124..bc25a23 100644 --- a/pydelta/PyDelta.py +++ b/pydelta/PyDelta.py @@ -78,13 +78,17 @@ def obfuscate_cli(): parser.add_argument('--no-refactor-names', action='store_false', help='Disables refactoring variable, function and args names.') parser.add_argument('--no-encrypt-str', action='store_false', help='Disables encrypting strings.') parser.add_argument('--no-compress-encrypt', action='store_false', help='Disables compression and encryption of the code.') + parser.add_argument('--no-utf-8', action='store_false', help='Do not use encoding=utf-8 to read input file.') parser.add_argument('--str-encryption-amount', type=int, default=3, help='Amount of times to encrypt strings.') parser.add_argument('--compress-encrypt-amount', type=int, default=30, help='Amount of times to compress and encrypt the code.') args = parser.parse_args() try: - with open(args.input_file, 'r') as infile: + my_encoding = 'iso8859_1' + if args.utf-8: + my_encoding = 'utf-8' + with open(args.input_file, 'r', encoding=my_encoding) as infile: source_code = infile.read() except Exception as e: raise Exception(f"Could not read input file: {str(e)}") @@ -105,4 +109,4 @@ def obfuscate_cli(): with open(args.output_file, 'w') as outfile: outfile.write(obfuscated_code) except Exception as e: - raise Exception(f"Could not write to file: {str(e)}") \ No newline at end of file + raise Exception(f"Could not write to file: {str(e)}") From 17850f0660fec7fbe91dc62269ce82c40fe73db3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Mar=C3=ADn?= Date: Fri, 5 Jul 2024 09:53:26 +0100 Subject: [PATCH 2/3] Update PyDelta.py Set locale preferred encoding as default to read input file --- pydelta/PyDelta.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pydelta/PyDelta.py b/pydelta/PyDelta.py index bc25a23..a4dedf9 100644 --- a/pydelta/PyDelta.py +++ b/pydelta/PyDelta.py @@ -4,6 +4,7 @@ # Annotation string references are currently broken import argparse +import locale from dataclasses import dataclass @@ -85,7 +86,7 @@ def obfuscate_cli(): args = parser.parse_args() try: - my_encoding = 'iso8859_1' + my_encoding = locale.getpreferredencoding() if args.utf-8: my_encoding = 'utf-8' with open(args.input_file, 'r', encoding=my_encoding) as infile: From 80d60b8521bf7a80f3efa548316f5d76a68ec75d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Mar=C3=ADn?= Date: Fri, 5 Jul 2024 10:14:17 +0100 Subject: [PATCH 3/3] Update PyDelta.py Set --utf-8 instead of --no-utf-8 in parser argument --- pydelta/PyDelta.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pydelta/PyDelta.py b/pydelta/PyDelta.py index a4dedf9..ca224a6 100644 --- a/pydelta/PyDelta.py +++ b/pydelta/PyDelta.py @@ -79,7 +79,7 @@ def obfuscate_cli(): parser.add_argument('--no-refactor-names', action='store_false', help='Disables refactoring variable, function and args names.') parser.add_argument('--no-encrypt-str', action='store_false', help='Disables encrypting strings.') parser.add_argument('--no-compress-encrypt', action='store_false', help='Disables compression and encryption of the code.') - parser.add_argument('--no-utf-8', action='store_false', help='Do not use encoding=utf-8 to read input file.') + parser.add_argument('--utf-8', action='store_false', help='Use encoding=utf-8 to read input file.') parser.add_argument('--str-encryption-amount', type=int, default=3, help='Amount of times to encrypt strings.') parser.add_argument('--compress-encrypt-amount', type=int, default=30, help='Amount of times to compress and encrypt the code.') @@ -87,7 +87,7 @@ def obfuscate_cli(): try: my_encoding = locale.getpreferredencoding() - if args.utf-8: + if args.utf_8: my_encoding = 'utf-8' with open(args.input_file, 'r', encoding=my_encoding) as infile: source_code = infile.read()