From 2a9dbdcba59e25a6a51cb5329d79ddbdb0824ba9 Mon Sep 17 00:00:00 2001
From: westernmeadow <wkwan626@gmail.com>
Date: Mon, 18 Sep 2023 11:49:44 -0700
Subject: [PATCH] updated decryption for forums utilities.py

---
 Forums/Utilities/utilities.py | 29 ++++++++++++-----------------
 1 file changed, 12 insertions(+), 17 deletions(-)

diff --git a/Forums/Utilities/utilities.py b/Forums/Utilities/utilities.py
index 741ec1f..2a5e2f0 100644
--- a/Forums/Utilities/utilities.py
+++ b/Forums/Utilities/utilities.py
@@ -353,29 +353,24 @@ def encrypt_encode_image_to_base64(driver, xpath):
     return None
 
 
-def decode_decrypt_image_in_base64(html_content):
+def decode_decrypt_image_in_base64(string_image):
 
-    soup = BeautifulSoup(html_content, 'html.parser')
-
-    for img_tag in soup.find_all('img'):
-
-        src_attr = img_tag.get('src')
+    try:
 
-        if src_attr and src_attr.startswith('data:image'):
+        base64_image = bytes(string_image, encoding='utf-8')
+        encrypted_image = base64.b64decode(base64_image)
+        decrypted_image = aes_decryption(encrypted_image)
 
-            try:
+        im = Image.open(io.BytesIO(decrypted_image))
+        im.show()
 
-                string_image = src_attr.split('base64,')[-1]
-                base64_image = bytes(string_image, encoding='utf-8')
-                encrypted_image = base64.b64decode(base64_image)
-                decrypted_image = aes_decryption(encrypted_image)
+        return decrypted_image
 
-                im = Image.open(io.BytesIO(decrypted_image))
-                im.show()
+    except Exception as e:
+        print(e)
+        pass
 
-            except Exception as e:
-                print(e)
-                pass
+    return None
 
 
 def replace_image_sources(driver, html_content):