From 7ddb89de7267621631bb48065d1579de7440ec3f Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Thu, 26 Mar 2026 09:12:44 +0000 Subject: [PATCH] fix: resolve CodeQL alert #19 - Use of a broken or weak cryptographic algorithm --- vulnerable_weak_crypto.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/vulnerable_weak_crypto.py b/vulnerable_weak_crypto.py index 5b8aca6..fa8f61b 100644 --- a/vulnerable_weak_crypto.py +++ b/vulnerable_weak_crypto.py @@ -10,9 +10,10 @@ def hash_with_sha1(data): return hashlib.sha1(data.encode()).hexdigest() def encrypt_data_des(data, key): - cipher = DES.new(key, DES.MODE_ECB) - encrypted = cipher.encrypt(data) - return encrypted + from Crypto.Cipher import AES + cipher = AES.new(key, AES.MODE_GCM) + ciphertext, tag = cipher.encrypt_and_digest(data) + return cipher.nonce + tag + ciphertext def encrypt_with_arc2(plaintext, key): cipher = ARC2.new(key, ARC2.MODE_ECB)