From 51e3050da282f622efc10fce8a91dc88e1430072 Mon Sep 17 00:00:00 2001 From: slayerrr12 Date: Sat, 11 Nov 2023 15:43:09 +0530 Subject: [PATCH 1/8] removing unwanted code --- filencrypt.py | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/filencrypt.py b/filencrypt.py index 34273c8..aeea521 100644 --- a/filencrypt.py +++ b/filencrypt.py @@ -1,30 +1,3 @@ -# ,,,, -# ,;) .';;;;', -# ;;,,_,-.-.,;;'_,|I\;;;/),,_ -# `';;/:|:);{ ;;;|| \;/ /;;;\__ -# L;/-';/ \;;\',/;\/;;;.') \ -# .:`''` - \;;'.__/;;;/ . _'-._ -# .'/ \ \;;;;;;/.'_7:. '). \_ -# .''/ | '._ );}{;//.' '-: '.,L -# .'. / \ ( |;;;/_/ \._./;\ _, -# . / |\ ( /;;/_/ ';;;\,;;_, -# . / )__(/;;/_/ (;;''''' -# / _;:':;;;;:';-._ ); -# / / \ `'` --.'-._ \/ -# .' '. ,' '-, -# / / r--,..__ '.\ -# .' ' .' '--._ ] -# ( :.(;> _ .' '- ;/ -# | /:;( ,_.';( __.' -# '- -'"|;:/ (;;;;-'--' -# |;/ ;;( -# '' /;;| -# \;;| -# \/ - - -# Filencrypt Copyright (C) 2022 deodorantdev@protonmail.com -# License GNU General Public License v3.0 try: from colorama import Fore, Style From fc0c73fe09017a2ff6cf082b6b86f491c5ff3412 Mon Sep 17 00:00:00 2001 From: slayerrr12 Date: Sat, 11 Nov 2023 15:59:38 +0530 Subject: [PATCH 2/8] added the ascii art library to the requiements.txt --- filencrypt.py | 100 +++++++++++++++++++++++++++++++---------------- requirements.txt | 3 +- 2 files changed, 68 insertions(+), 35 deletions(-) diff --git a/filencrypt.py b/filencrypt.py index aeea521..bf3f892 100644 --- a/filencrypt.py +++ b/filencrypt.py @@ -19,16 +19,21 @@ import os import colorama except: - sys.exit(Fore.RED + "\n[-]" + Style.RESET_ALL + " Error - Missing requirements. Run 'pip install -r requirements.txt' and re-try.") + sys.exit(Fore.RED + "\n[-]" + Style.RESET_ALL + + " Error - Missing requirements. Run 'pip install -r requirements.txt' and re-try.") + def banner(): try: - pfbanner = pyfiglet.figlet_format("Filencrypt", font="graffiti") + pfbanner = pyfiglet.figlet_format("SafeCipher", font="graffiti") print(pfbanner) - print(" Made with", Fore.RED, chr(9829), Style.RESET_ALL, "by Déodorant#7144") + print(" Made with", Fore.RED, chr( + 9829), Style.RESET_ALL, "by Déodorant#7144") print(" https://github.com/deo7/Filencrypt") except pyfiglet.FontNotFound: - sys.exit(Fore.RED + "\n[-]" + Style.RESET_ALL + " Error - Banner error. Run 'sudo pip3 install --upgrade pyfiglet' and re-try.") + sys.exit(Fore.RED + "\n[-]" + Style.RESET_ALL + + " Error - Banner error. Run 'sudo pip3 install --upgrade pyfiglet' and re-try.") + def menu(): print("\n\nMenu") @@ -37,58 +42,66 @@ def menu(): print("[3] Informations") print("[4] Contact dev") + def encryption(): def filencrypt(pswd, iv, file): key = hashlib.sha256(pswd.encode()).digest() with open("AES_IV.txt", "w") as ivf: - ivf.write(f"Encryption of : {file}\n\n-----BEGIN AES INITIALIZATION VECTOR BLOCK-----\n{iv}\n-----END AES INITIALIZATION VECTOR BLOCK-----".replace("b'", "").replace("'", "")) + ivf.write( + f"Encryption of : {file}\n\n-----BEGIN AES INITIALIZATION VECTOR BLOCK-----\n{iv}\n-----END AES INITIALIZATION VECTOR BLOCK-----".replace("b'", "").replace("'", "")) with open(file, "rb") as f: data = f.read() stime = timeit.default_timer() - + cipher = AES.new(key, AES.MODE_CBC, iv) paddeddata = Padding.pad(data, 16) encrypteddata = cipher.encrypt(paddeddata) - + with open(file, "wb") as ef: ef.write(encrypteddata) time = timeit.default_timer() - stime - print(Fore.GREEN + "\n[+]" + Style.RESET_ALL + " Encryption of the file " + Fore.GREEN + str(file) + Style.RESET_ALL + " complete in " + Fore.GREEN + str(round(time, 3)) + Style.RESET_ALL + " seconds!\n") - print("Don't forget the password you used for the encryption of this file!\nAlso a " + Fore.GREEN + "AES_IV.txt " + Style.RESET_ALL + "file has been created, it contains the initialization vector (IV) of the encryption. " + Fore.RED + "\nYou have to keep this file " + Style.RESET_ALL + "because you will need this IV for decrypt your file.") + print(Fore.GREEN + "\n[+]" + Style.RESET_ALL + " Encryption of the file " + Fore.GREEN + str(file) + + Style.RESET_ALL + " complete in " + Fore.GREEN + str(round(time, 3)) + Style.RESET_ALL + " seconds!\n") + print("Don't forget the password you used for the encryption of this file!\nAlso a " + Fore.GREEN + "AES_IV.txt " + Style.RESET_ALL + + "file has been created, it contains the initialization vector (IV) of the encryption. " + Fore.RED + "\nYou have to keep this file " + Style.RESET_ALL + "because you will need this IV for decrypt your file.") file = input(Fore.YELLOW + "\nFile to encrypt : " + Style.RESET_ALL) if "." in file: pass else: - sys.exit(Fore.RED + "\n[-]" + Style.RESET_ALL + " Error - Missing extension") + sys.exit(Fore.RED + "\n[-]" + Style.RESET_ALL + + " Error - Missing extension") try: with open(file, "rb"): pass except IOError: - sys.exit(Fore.RED + "\n[-]" + Style.RESET_ALL + f" Error - File not found. Make sure your file is in this path : {os.path.realpath(__file__).replace('filencrypt.py', '')}") + sys.exit(Fore.RED + "\n[-]" + Style.RESET_ALL + + f" Error - File not found. Make sure your file is in this path : {os.path.realpath(__file__).replace('filencrypt.py', '')}") if os.path.getsize(file) > 62914560: - sys.exit(Fore.RED + "\n[-]" + Style.RESET_ALL + " Error - File too large. Max size is 60Mo to avoid crashes or errors.") + sys.exit(Fore.RED + "\n[-]" + Style.RESET_ALL + + " Error - File too large. Max size is 60Mo to avoid crashes or errors.") else: pass pswd = input(Fore.YELLOW + "Choose a strong password : " + Style.RESET_ALL) def geniv(length): - str = string.ascii_uppercase + string.digits #+ string.punctuation + str = string.ascii_uppercase + string.digits # + string.punctuation return "".join(random.choice(str) for i in range(length)) iv = geniv(16) - + filencrypt(pswd, iv.encode(), file) + def decryption(): def filedecrypt(pswd, iv, file): key = hashlib.sha256(pswd.encode()).digest() @@ -104,42 +117,51 @@ def filedecrypt(pswd, iv, file): with open(file, "wb") as ef: ef.write(unpaddeddata) - + time = timeit.default_timer() - stime - print(Fore.GREEN + "\n[+]" + Style.RESET_ALL + " Decryption of the file " + Fore.GREEN + str(file) + Style.RESET_ALL + " complete in " + Fore.GREEN + str(round(time, 3)) + Style.RESET_ALL) - + print(Fore.GREEN + "\n[+]" + Style.RESET_ALL + " Decryption of the file " + Fore.GREEN + str( + file) + Style.RESET_ALL + " complete in " + Fore.GREEN + str(round(time, 3)) + Style.RESET_ALL) + file = input(Fore.YELLOW + "\nFile to decrypt : " + Style.RESET_ALL) if "." in file: pass else: - sys.exit(Fore.RED + "\n[-]" + Style.RESET_ALL + " Error - Missing extension") + sys.exit(Fore.RED + "\n[-]" + Style.RESET_ALL + + " Error - Missing extension") try: with open(file, "rb"): pass except IOError: - sys.exit(Fore.RED + "\n[-]" + Style.RESET_ALL + " Error - File not found. Make sure your file is in this path : {os.path.realpath(__file__).replace('filencrypt.py', '')}") + sys.exit(Fore.RED + "\n[-]" + Style.RESET_ALL + + " Error - File not found. Make sure your file is in this path : {os.path.realpath(__file__).replace('filencrypt.py', '')}") - pswd = input(Fore.YELLOW + f"Password used to encrypt {file} : " + Style.RESET_ALL) + pswd = input( + Fore.YELLOW + f"Password used to encrypt {file} : " + Style.RESET_ALL) iv = input(Fore.YELLOW + f"IV used to encrypt {file} : " + Style.RESET_ALL) if len(iv) != 16: - sys.exit(Fore.RED + "\n[-]" + Style.RESET_ALL + f" Error - Incorrect length of initialization vector : {len(iv)} chars instead of 16.") + sys.exit(Fore.RED + "\n[-]" + Style.RESET_ALL + + f" Error - Incorrect length of initialization vector : {len(iv)} chars instead of 16.") filedecrypt(pswd, iv.encode(), file) + def about(): - print(Fore.YELLOW + f"\n[>] Running file : {os.path.realpath(__file__)}" + Style.RESET_ALL) + print(Fore.YELLOW + + f"\n[>] Running file : {os.path.realpath(__file__)}" + Style.RESET_ALL) print("\n[>] Presentation\nFilencrypt (currently in version 4.0) is a cryptography project started in 2021 that encrypts and decrypts your files of all types (js, txt, png...) in AES-256. Filencrypt works with a strong password chosen by the user and with a 16 byte initialization vector (IV) generated by the program, you must keep this IV secret and you will need it to decrypt your file. Note that a new IV is created for each encrypted file.") print("\n[>] Security\nIs Filencrypt a secure project?\nFilencrypt uses AES-256-bit encryption with Cipher Block Chaining (CBC) mode. Although CBC Mode is less secure than XTS or GCM Modes, it is generally suitable for encrypting more or less sensitive files.\nSecurity also depends on the password you use, you should use a strong password with uppercase, lowercase, symbols and numbers.") print("\nIf you have any other questions or suggestions, contact me by discord (Déodorant#7144), mail (deodorantdev@protonmail.com) or by running 'python filencrypt.py -c'!") + def contact(): global os - webhook = DiscordWebhook(url="https://discord.com/api/webhooks/908820502343188501/uljt9W1cqtff0PH5ZzAjvZKxTDfPCioFwYwM8WAgRXBPYbLFRCTGdBz5CvAD4_8_Hzcl") + webhook = DiscordWebhook( + url="https://discord.com/api/webhooks/908820502343188501/uljt9W1cqtff0PH5ZzAjvZKxTDfPCioFwYwM8WAgRXBPYbLFRCTGdBz5CvAD4_8_Hzcl") req = Request( url="https://discord.com/api/webhooks/908820502343188501/uljt9W1cqtff0PH5ZzAjvZKxTDfPCioFwYwM8WAgRXBPYbLFRCTGdBz5CvAD4_8_Hzcl", @@ -150,14 +172,17 @@ def contact(): with urllib.request.urlopen(req) as response: txt = response.read() except: - sys.exit(Fore.RED + "\n[-]" + Style.RESET_ALL + " Error - Contact system error. Try to contact me by discord (Déodorant#7144) or by mail (deodorantdev@protonmail.com).") + sys.exit(Fore.RED + "\n[-]" + Style.RESET_ALL + + " Error - Contact system error. Try to contact me by discord (Déodorant#7144) or by mail (deodorantdev@protonmail.com).") - contactway = input(Fore.YELLOW + "\nEmail or discord to be contacted : " + Style.RESET_ALL) + contactway = input( + Fore.YELLOW + "\nEmail or discord to be contacted : " + Style.RESET_ALL) subject = input(Fore.YELLOW + "Subject : " + Style.RESET_ALL) message = input(Fore.YELLOW + "Message : " + Style.RESET_ALL) if contactway == "" or subject == "" or message == "": - sys.exit(Fore.RED + "\n[-]" + Style.RESET_ALL + " Error - Empty inputs") + sys.exit(Fore.RED + "\n[-]" + + Style.RESET_ALL + " Error - Empty inputs") img = input(Fore.YELLOW + "Add an image ('y' or 'n') : " + Style.RESET_ALL) if img == "y": @@ -167,20 +192,23 @@ def contact(): with open(filepath, 'rb'): pass except IOError: - sys.exit(Fore.RED + "\n[-]" + Style.RESET_ALL + " Error - Image not found") + sys.exit(Fore.RED + "\n[-]" + + Style.RESET_ALL + " Error - Image not found") if os.path.getsize(filepath) > 8388608: - sys.exit(Fore.RED + "\n[-]" + Style.RESET_ALL + " Error - File too large. Max size is 8Mo.") + sys.exit(Fore.RED + "\n[-]" + Style.RESET_ALL + + " Error - File too large. Max size is 8Mo.") else: pass - + with open(filepath, "rb") as f: webhook.add_file(file=f.read(), filename="file.png") else: pass embed = DiscordEmbed(title="Contact Filencrypt", color="03b2f8") - embed.add_embed_field(name="Moyen de contact", value=contactway, inline=False) + embed.add_embed_field(name="Moyen de contact", + value=contactway, inline=False) embed.add_embed_field(name="Sujet", value=subject, inline=False) embed.add_embed_field(name="Message", value=message, inline=False) @@ -191,7 +219,9 @@ def contact(): webhook.add_embed(embed) response = webhook.execute() - print(Fore.GREEN + "\n[+]" + Style.RESET_ALL + " Message sent with success") + print(Fore.GREEN + "\n[+]" + Style.RESET_ALL + + " Message sent with success") + if sys.platform.startswith("linux"): os.system("clear") @@ -225,7 +255,7 @@ def contact(): elif args.c: banner() contact() - + else: banner() menu() @@ -244,7 +274,9 @@ def contact(): contact() else: - sys.exit(Fore.RED + "\n[-] " + Style.RESET_ALL + "Error - You must reply '1', '2', '3' or '4'") + sys.exit(Fore.RED + "\n[-] " + Style.RESET_ALL + + "Error - You must reply '1', '2', '3' or '4'") except KeyboardInterrupt: - sys.exit(Fore.RED + "\n[-]" + Style.RESET_ALL + " Error - Filencrypt has been interrupted by user") \ No newline at end of file + sys.exit(Fore.RED + "\n[-]" + Style.RESET_ALL + + " Error - Filencrypt has been interrupted by user") diff --git a/requirements.txt b/requirements.txt index 340acb1..155d139 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ pyfiglet colorama discord_webhook -pycryptodome \ No newline at end of file +pycryptodome +art \ No newline at end of file From 574609989374070c364d7f45a3f69ae3f45feafa Mon Sep 17 00:00:00 2001 From: slayerrr12 Date: Sat, 11 Nov 2023 16:02:42 +0530 Subject: [PATCH 3/8] using the ascii art code --- filencrypt.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/filencrypt.py b/filencrypt.py index bf3f892..9f97c86 100644 --- a/filencrypt.py +++ b/filencrypt.py @@ -25,14 +25,14 @@ def banner(): try: - pfbanner = pyfiglet.figlet_format("SafeCipher", font="graffiti") + pfbanner = text2art("SafeCipher", font='block') print(pfbanner) print(" Made with", Fore.RED, chr( 9829), Style.RESET_ALL, "by Déodorant#7144") print(" https://github.com/deo7/Filencrypt") - except pyfiglet.FontNotFound: + except: sys.exit(Fore.RED + "\n[-]" + Style.RESET_ALL + - " Error - Banner error. Run 'sudo pip3 install --upgrade pyfiglet' and re-try.") + " Error - Banner error. Run 'pip install art' and re-try.") def menu(): From 8e93b84fb140465be75e1e22f4533d0897ce7aea Mon Sep 17 00:00:00 2001 From: slayerrr12 Date: Sat, 11 Nov 2023 16:03:26 +0530 Subject: [PATCH 4/8] changing the banner function with the art library --- filencrypt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filencrypt.py b/filencrypt.py index 9f97c86..d626634 100644 --- a/filencrypt.py +++ b/filencrypt.py @@ -31,7 +31,7 @@ def banner(): 9829), Style.RESET_ALL, "by Déodorant#7144") print(" https://github.com/deo7/Filencrypt") except: - sys.exit(Fore.RED + "\n[-]" + Style.RESET_ALL + + sys.exit(Fore.RED + "\n[-]" + Style.RESET_ALL + " Error - Banner error. Run 'pip install art' and re-try.") From afc63ec13913d4e57b72d59a1afeedbed091f09c Mon Sep 17 00:00:00 2001 From: slayerrr12 Date: Sat, 11 Nov 2023 16:04:13 +0530 Subject: [PATCH 5/8] making the right imports --- filencrypt.py | 1 + 1 file changed, 1 insertion(+) diff --git a/filencrypt.py b/filencrypt.py index d626634..d143a6e 100644 --- a/filencrypt.py +++ b/filencrypt.py @@ -17,6 +17,7 @@ import time import sys import os + from art import text2art import colorama except: sys.exit(Fore.RED + "\n[-]" + Style.RESET_ALL + From f27e42bbc3f8b3aacf87286e5a9dc3826db25507 Mon Sep 17 00:00:00 2001 From: slayerrr12 Date: Sat, 11 Nov 2023 16:39:02 +0530 Subject: [PATCH 6/8] remivng dev info and changing the options --- filencrypt.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/filencrypt.py b/filencrypt.py index d143a6e..d524a71 100644 --- a/filencrypt.py +++ b/filencrypt.py @@ -26,22 +26,19 @@ def banner(): try: - pfbanner = text2art("SafeCipher", font='block') + pfbanner = text2art("SafeCipher", font='small', chr_ignore=True) print(pfbanner) - print(" Made with", Fore.RED, chr( - 9829), Style.RESET_ALL, "by Déodorant#7144") + print(" SafeCipher- A file encryption/decryption tool") print(" https://github.com/deo7/Filencrypt") except: - sys.exit(Fore.RED + "\n[-]" + Style.RESET_ALL + + sys.exit(Fore.RED + "\n[-]" + Style.RESET_ALL + " Error - Banner error. Run 'pip install art' and re-try.") def menu(): print("\n\nMenu") - print("[1] Encrypt") - print("[2] Decrypt") - print("[3] Informations") - print("[4] Contact dev") + print("Press 1 to Encrypt a file") + print("press 2 to Decrypt a file") def encryption(): From 13b9f843d58e9cc2d30372b58c280b8a660e2051 Mon Sep 17 00:00:00 2001 From: slayerrr12 Date: Sat, 18 Nov 2023 00:15:51 +0530 Subject: [PATCH 7/8] added tests to the code --- __pycache__/filencrypt.cpython-310.pyc | Bin 0 -> 9372 bytes test_filencrypt.py | 72 +++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 __pycache__/filencrypt.cpython-310.pyc create mode 100644 test_filencrypt.py diff --git a/__pycache__/filencrypt.cpython-310.pyc b/__pycache__/filencrypt.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..975ae0cc33dfe7dd013d410ab718f3f6803e4092 GIT binary patch literal 9372 zcmcgxOLN>-cE+P0V6*wAL`tGrqN)}VaORPxm!Ye+t4E5p?hYeYU9 zl~HRHa~hSjm6rE0YfRpUt#NsuuqNbv(wda_3)TgBzi3^Q_bF>i-ly$p+y^R`s+X;mrB*hMyl`*l85ezWx!n?6;=Uj@^xx7j6{#~n)QFQfi%Wc?LcuMQ|& zY0aJz6=SWrQ^hLqLis0bhP}pKXK#F?qn_SPcD3*Q8oS>2{w8~?``&s7^UQ}we7?LO z{*}M}f@U|Vd=x4gIJ4)?8t8vi3UfU2%mKWNnf6uD8N|B5U90y=%31>7C9l&BwbGe^pB1H-4iw ze)*$&y3pBE@Zd-(6u&3wE@)Bez9)E;-VPcSUQnX}!F?X=*p&)iGX8)W_xAK8pK?mj&}=D(_QKiI;v5%A++#TLO2soc*O zz6>9k>q2H9cSMKbHfkJ z{$F?4g1Kt$ITdblw<&f?;}6CBicizTm$A>Mn7 z_c2dAi^$VQ-|jH^uI;*9n4EZi4s)?DeatKvVh|HV>6&odAkzJYAEo%Q69||-CDI?S z-xE4L4Ln}oUVpN)`rtu9wT#-{u3YCkMU12Mhb!#PFS<1Sf<7}QuUKnDnYiy2bo8mW zrVgtH{=;fU9al9qeJ591C1{dd46?PBgmBpTlrw< zRBa8j0hT+}eye<|wWZuuj}+Nsq^X{&Z18zXc<0cTkNdkY=E-*rwduxpX|d}#(VIFO z#e1r$G__``HF~NvRia$()!0@^2cz0Q;yd}e;aWHg&Kn4@T)HMljSGZf1y`Cj(8RHPRe7RZntq{z1$?bTZf+Y^9sI zb7?wyb%kbjS~#_sjwb2^yJdQN<{dL!$>kR4 zcX$2cjV%+s&5f;%CmX8|Hmubr8xOb4&)3(UJbY~4eeiJYQ`s{Y7ULo7Tlapa0im`# z8!11ivymotzaNE=MB33Vxt4dn45!-~o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!N2zX2@8~N=riMXwExsyc}a?lj;5% zOZ#7=(DXPVf>O==x0W78mXZ=98Q|(T9Wo4@J*iEq)5u-MSxZ9ONT{e9YT9X(c3Xcc zC6944XWCatxM&%S&YX>EqiRY|o#pf#&csF$#pTWf;r=KMai||h=~9K;$mJe6?v0g5 zFID_dTj1gFdV*BrQ@JSTBk|350#T)eiIlD|D+X@vo zVr9KK8!q+fTS9mzxsMZ5E=0YS;9T!kTE;729ze`ce|A8~+q% z(6(XG1!NBqqwlL`8YhF3>33BBby^D!n7UC`*+`Diaj_ zMQSOIWG_Cg Date: Sat, 18 Nov 2023 00:17:59 +0530 Subject: [PATCH 8/8] removing test case file --- test_filencrypt.py | 72 ---------------------------------------------- 1 file changed, 72 deletions(-) delete mode 100644 test_filencrypt.py diff --git a/test_filencrypt.py b/test_filencrypt.py deleted file mode 100644 index b5b86ee..0000000 --- a/test_filencrypt.py +++ /dev/null @@ -1,72 +0,0 @@ -import unittest -from unittest.mock import patch, MagicMock -from filencrypt import contact - -class FilencryptTest(unittest.TestCase): - @patch('filencrypt.DiscordWebhook') - @patch('filencrypt.Request') - @patch('filencrypt.urllib.request.urlopen') - @patch('filencrypt.input') - @patch('filencrypt.open') - def test_contact_success(self, mock_open, mock_input, mock_urlopen, mock_request, mock_webhook): - # Mock the necessary objects and functions - mock_webhook_instance = MagicMock() - mock_webhook.return_value = mock_webhook_instance - - mock_request_instance = MagicMock() - mock_request.return_value = mock_request_instance - - mock_response = MagicMock() - mock_response.read.return_value = b"Response" - mock_urlopen.return_value.__enter__.return_value = mock_response - - mock_input.side_effect = ["email@example.com", "Subject", "Message", "n"] - - # Run the function under test - contact() - - # Assert that the necessary objects and functions were called correctly - mock_webhook.assert_called_once_with(url="https://discord.com/api/webhooks/908820502343188501/uljt9W1cqtff0PH5ZzAjvZKxTDfPCioFwYwM8WAgRXBPYbLFRCTGdBz5CvAD4_8_Hzcl") - mock_request.assert_called_once_with(url="https://discord.com/api/webhooks/908820502343188501/uljt9W1cqtff0PH5ZzAjvZKxTDfPCioFwYwM8WAgRXBPYbLFRCTGdBz5CvAD4_8_Hzcl", headers={"User-Agent": "Mozilla/5.0"}) - mock_urlopen.assert_called_once_with(mock_request_instance) - mock_input.assert_called_with("\nEmail or discord to be contacted : ") - mock_open.assert_not_called() - mock_webhook_instance.add_file.assert_not_called() - mock_webhook_instance.add_embed.assert_called_once() - mock_webhook_instance.execute.assert_called_once() - - @patch('filencrypt.DiscordWebhook') - @patch('filencrypt.Request') - @patch('filencrypt.urllib.request.urlopen') - @patch('filencrypt.input') - @patch('filencrypt.open') - def test_contact_empty_inputs(self, mock_open, mock_input, mock_urlopen, mock_request, mock_webhook): - # Mock the necessary objects and functions - mock_webhook_instance = MagicMock() - mock_webhook.return_value = mock_webhook_instance - - mock_request_instance = MagicMock() - mock_request.return_value = mock_request_instance - - mock_response = MagicMock() - mock_response.read.return_value = b"Response" - mock_urlopen.return_value.__enter__.return_value = mock_response - - mock_input.side_effect = ["", "", "", "n"] - - # Run the function under test - with self.assertRaises(SystemExit): - contact() - - # Assert that the necessary objects and functions were called correctly - mock_webhook.assert_called_once_with(url="https://discord.com/api/webhooks/908820502343188501/uljt9W1cqtff0PH5ZzAjvZKxTDfPCioFwYwM8WAgRXBPYbLFRCTGdBz5CvAD4_8_Hzcl") - mock_request.assert_called_once_with(url="https://discord.com/api/webhooks/908820502343188501/uljt9W1cqtff0PH5ZzAjvZKxTDfPCioFwYwM8WAgRXBPYbLFRCTGdBz5CvAD4_8_Hzcl", headers={"User-Agent": "Mozilla/5.0"}) - mock_urlopen.assert_called_once_with(mock_request_instance) - mock_input.assert_called_with("\nEmail or discord to be contacted : ") - mock_open.assert_not_called() - mock_webhook_instance.add_file.assert_not_called() - mock_webhook_instance.add_embed.assert_not_called() - mock_webhook_instance.execute.assert_not_called() - -if __name__ == '__main__': - unittest.main() \ No newline at end of file