diff --git a/.gitignore b/.gitignore index 1e0fbcd5b..1ae708dbc 100644 --- a/.gitignore +++ b/.gitignore @@ -152,4 +152,5 @@ dmypy.json # Cython debug symbols cython_debug/ -*.db \ No newline at end of file +*.db +.idea/ \ No newline at end of file diff --git a/README.md b/README.md index 54d7c5e7b..9e416eaa9 100644 --- a/README.md +++ b/README.md @@ -874,14 +874,21 @@ Tyler-Pear + + + Gabriela20103967 +
+ Gabriela20103967 +
+ + bim22614
Bim22614
- - + jrbublitz @@ -916,15 +923,15 @@
Nayan Chandak
- + + DevTomilola-OS
Oluwatomilola
- - + herepete @@ -959,15 +966,15 @@
Kartik Nandagaon
- + + SirRomey
SirRomey
- - + ZackeryRSmith @@ -1002,15 +1009,15 @@
Harry830
- + + MrB141107
Mr.B
- - + EFFLUX110 @@ -1045,15 +1052,15 @@
Yash Parwal
- + + Zedeldi
Zack Didcott
- - + asingh4451 @@ -1088,15 +1095,15 @@
Adrija
- + + advik-student-dev
Advik Sharma
- - + tamojeetK @@ -1131,15 +1138,15 @@
Soonam Kalyan Panda
- + + Logadheep
Logadheep
- - + MattBlodgettProjects @@ -1174,15 +1181,15 @@
Rajdeep Das
- + + ShivaNagachander
SHIVA NC
- - + shashaaankkkkk @@ -1217,15 +1224,15 @@
Ota Hina
- + + parth-verma7
Parth Verma
- - + sirKiraUzumaki @@ -1260,15 +1267,15 @@
Chirag Aggarwal
- + + kom-senapati
Kom Senapati
- - + u749929 @@ -1303,15 +1310,15 @@
Akarsh Bajpai
- + + blindaks
Akrati Verma
- - + amoghak-ds @@ -1346,15 +1353,15 @@
CJ Praveen
- + + iamdestinychild
Destiny
- - + Devparihar5 @@ -1389,15 +1396,15 @@
Govind S Nair
- + + ducheharsh
Harsh Mahadev Duche
- - + HridayAg0102 @@ -1405,6 +1412,13 @@ Hriday Agrawal + + + WhoIsJayD +
+ Jaydeep +
+ khushhalgarg112 @@ -1425,7 +1439,8 @@
MINHAJ
- + + manav0702 @@ -1439,8 +1454,7 @@
Meep_
- - + rust-master @@ -1468,7 +1482,8 @@
Raj Saha
- + + robertlent @@ -1482,8 +1497,7 @@
Saanvibk
- - + Petsamuel @@ -1511,7 +1525,8 @@
Syeda Nowshin Ibnat
- + + Utkarsh-Raj20 @@ -1525,8 +1540,7 @@
Dapo Adedire
- - + dimonalik @@ -1548,28 +1562,21 @@ Maglionaire - - - Gabriela20103967 -
- Gabriela20103967 -
- Guillotine189
Sarthak Singhal
- + + newtoallofthis123
Ishan Joshi
- - + Rathish-Rajendran @@ -1604,15 +1611,15 @@
Abhay-Gupta008
- + + AbhinandanSingla
Abhinandan Singla
- - + adixoo @@ -1647,15 +1654,15 @@
Arif Shariar Rahman
- + + AtharvaDeshmukh0909
AtharvaDeshmukh0909
- - + ayushi-ras @@ -1663,6 +1670,20 @@ Ayushi Rastogi + + + bhanushri123 +
+ Bhanushri Chinta +
+ + + + Carl283583 +
+ Carl283583 +
+ Crack-er-jack @@ -1676,7 +1697,8 @@
David-hosting
- + + Dhandeep10 @@ -1697,8 +1719,7 @@
Dishant Nagpal
- - + EbrG786 @@ -1719,7 +1740,8 @@
HarsH
- + + HimanshuSinghNegi @@ -1740,8 +1762,7 @@
Jishnudeep Borah
- - + Josephtobi @@ -1762,7 +1783,8 @@
Krishna13515
- + + iamkunalpitale @@ -1783,8 +1805,7 @@
Mohamed Khaled Yousef
- - + jusinamine @@ -1805,7 +1826,8 @@
Nischay Goyal
- + + NooBIE-Nilay @@ -1826,8 +1848,7 @@
Prajwol Shrestha
- - + pranavdasan @@ -1848,7 +1869,8 @@
Faris Faikar
- + + Raashika0201 @@ -1869,8 +1891,7 @@
Raveny
- - + RishiPastor05 @@ -1891,7 +1912,8 @@
Sai Uttej R
- + + samayita1606 @@ -1899,6 +1921,13 @@ Samayita Kali + + + Sergey18273 +
+ Sergey18273 +
+ CapedDemon @@ -1912,8 +1941,7 @@
Shubham Kumar
- - + sudhanshu-77 @@ -1927,7 +1955,8 @@
Suliman Sagindykov
- + + sumitbaroniya @@ -1955,8 +1984,7 @@
Vikash
- - + Vishvam10 @@ -1970,7 +1998,8 @@
Vivek Kumar Gupta
- + + YashTariyal @@ -1998,8 +2027,7 @@
Ambush
- - + wre9-tesh @@ -2013,7 +2041,8 @@
Prajwal Benedict A
- + + chimerson @@ -2041,8 +2070,7 @@
Darsh Baxi
- - + faizaslam11 @@ -2056,7 +2084,8 @@
Dhruv Jagdish
- + + jonascarvalh @@ -2084,8 +2113,7 @@
Zainab Ibraheem
- - + mr-desilva @@ -2099,7 +2127,8 @@
Muchamad Yuda Tri Ananda
- + + NebulaAnish @@ -2127,8 +2156,7 @@
Prabin Shrestha
- - + pratyusha0710 @@ -2142,7 +2170,8 @@
Samual Martin
- + + rathoreshreya diff --git a/projects/AES256/AES256.py b/projects/AES256/AES256.py index 6c0836d59..ffa635bcc 100644 --- a/projects/AES256/AES256.py +++ b/projects/AES256/AES256.py @@ -1,5 +1,3 @@ -# AES 256 Encryption/Decryption Using pycryptodome Library - # Imports import hashlib from base64 import b64encode, b64decode @@ -8,7 +6,7 @@ from Cryptodome.Random import get_random_bytes import platform -# For different OS +# Clear the console screen if platform.system() == "Windows": os.system("cls") else: @@ -17,18 +15,14 @@ # Start of Encryption Function def encrypt(plain_text, password): - # generate a random salt - salt = get_random_bytes(AES.block_size) + if not password: + raise ValueError("Password cannot be empty.") - # use the Scrypt KDF to get a private key from the password + salt = get_random_bytes(AES.block_size) private_key = hashlib.scrypt( password.encode(), salt=salt, n=2**14, r=8, p=1, dklen=32 ) - - # create cipher config cipher_config = AES.new(private_key, AES.MODE_GCM) - - # return a dictionary with the encrypted text cipher_text, tag = cipher_config.encrypt_and_digest(bytes(plain_text, "utf-8")) return { "cipher_text": b64encode(cipher_text).decode("utf-8"), @@ -40,48 +34,55 @@ def encrypt(plain_text, password): # Start of Decryption Function def decrypt(enc_dict, password): - # decode the dictionary entries from base64 - salt = b64decode(enc_dict["salt"]) - cipher_text = b64decode(enc_dict["cipher_text"]) - nonce = b64decode(enc_dict["nonce"]) - tag = b64decode(enc_dict["tag"]) - - # generate the private key from the password and salt - private_key = hashlib.scrypt( - password.encode(), salt=salt, n=2**14, r=8, p=1, dklen=32 - ) - - # create the cipher config - cipher = AES.new(private_key, AES.MODE_GCM, nonce=nonce) - - # decrypt the cipher text - decrypted = cipher.decrypt_and_verify(cipher_text, tag) - - return decrypted + if not password: + raise ValueError("Password cannot be empty.") + + try: + salt = b64decode(enc_dict["salt"]) + cipher_text = b64decode(enc_dict["cipher_text"]) + nonce = b64decode(enc_dict["nonce"]) + tag = b64decode(enc_dict["tag"]) + private_key = hashlib.scrypt( + password.encode(), salt=salt, n=2**14, r=8, p=1, dklen=32 + ) + cipher = AES.new(private_key, AES.MODE_GCM, nonce=nonce) + decrypted = cipher.decrypt_and_verify(cipher_text, tag) + return decrypted.decode("utf-8") + except (ValueError, KeyError) as e: + raise ValueError("Invalid encrypted message format.") from e def main(): print("\t\tAES 256 Encryption and Decryption Algorithm") print("\t\t-------------------------------------------\n\n") - x = input("Enter 1 to encrypt and 2 to decrypt :") - if x == 1: + x = input("Enter 1 to encrypt and 2 to decrypt: ") + if x == "1": password = input("Enter the Password: ") secret_mssg = input("\nEnter the Secret Message: ") - # First let us encrypt secret message + # First, let us encrypt the secret message encrypted = encrypt(secret_mssg, password) print("\n\nEncrypted:") print("---------------\n") - print("\n".join("{}: {}".format(k, v) for k, v in encrypted.items())) - - # Now let us decrypt the message using our original password - if x == 2: - encrypted = input("Enter the encrypted message") - password = input("Enter the password") - decrypted = decrypt(encrypted, password) - print("\n\nDecrypted:") - print("-----------------\n") - print(bytes.decode(decrypted)) - - -main() + for k, v in encrypted.items(): + print(f"{k}: {v}") + + elif x == "2": + try: + encrypted = {} + encrypted["cipher_text"] = input("Enter the cipher text: ") + encrypted["salt"] = input("Enter the salt: ") + encrypted["nonce"] = input("Enter the nonce: ") + encrypted["tag"] = input("Enter the tag: ") + password = input("Enter the password: ") + + decrypted = decrypt(encrypted, password) + print("\n\nDecrypted:") + print("-----------------\n") + print(decrypted) + except ValueError as e: + print(f"Error: {e}") + + +if __name__ == "__main__": + main() diff --git a/projects/BlackJack/black_jack.py b/projects/BlackJack/black_jack.py index 8dfbc5f53..e58160950 100644 --- a/projects/BlackJack/black_jack.py +++ b/projects/BlackJack/black_jack.py @@ -114,7 +114,7 @@ def check_ace(card): BlackJack means 21. Whoever gets a total value of 21 with their cards immediately wins! (winning through blackjack results in 3x the money) -If the value of cards goes over 21, its called a BUST, which results in immediate loss... +If the value of cards goes over 21, it's called a BUST, which results in an immediate loss... If both the players get the same value of cards , it's a TIE and the bet money is returned. If none of the above cases are met ,the person with closer value to 21 wins. @@ -138,6 +138,8 @@ def check_ace(card): if bet > chips: print("You dont have enough chips.") print("Enter a valid amount. \n") + elif bet <= 0: # To prevent betting a negative value + print("Invalid Bet") else: chips -= bet break @@ -283,8 +285,9 @@ def check_ace(card): else: cont = input("Do you want to continue? (y/n) :") + check = cont.upper() ###So a capital or lowercase value can be entered - if cont == "y": + if check == "Y": print("\n" * 100) print( diff --git a/projects/Calendar/displayCalendar.py b/projects/Calendar/displayCalendar.py index 05d6e6a61..d5f9e632c 100644 --- a/projects/Calendar/displayCalendar.py +++ b/projects/Calendar/displayCalendar.py @@ -1,13 +1,13 @@ # Program to display calendar -def display_calendar(y, m): +def display_calendar(year, month): import calendar - print(calendar.month(y, m)) + print(calendar.month(year, month)) -y = int(input("Enter year: ")) -m = int(input("Enter month: ")) +year = int(input("Enter year: ")) +month = int(input("Enter month: ")) -display_calendar(y, m) +display_calendar(year, month) diff --git a/projects/Guess Number/guess_number.py b/projects/Guess Number/guess_number.py index 7882a90a9..b1b344b60 100644 --- a/projects/Guess Number/guess_number.py +++ b/projects/Guess Number/guess_number.py @@ -5,6 +5,7 @@ larger_number = 10 upper_limit = 10 lower_limit = 1 +num_of_guesses=0 # function to prompt user for input. will continue to ask user for proper int if invalid num passed @@ -35,13 +36,16 @@ def guess(num, user_guess): print(f"\nNumber is higher than {user_guess}") lower_limit = user_guess user_guess = enter_and_verification(lower_limit + 1, upper_limit) + num_of_guesses++ elif num < user_guess: print(f"\nNumber is lower than {user_guess}") upper_limit = user_guess user_guess = enter_and_verification(lower_limit, upper_limit - 1) + num_of_guesses++ else: print() print(f"\nCongrats! You've guessed the correct number! It was {num}.\n") + print("\nYou have tried {num_of_guesses} times to find the number.\n") # while loop to prompt user to play intially, then continue to play or not diff --git a/projects/ToDoList/to_do_list.py b/projects/ToDoList/to_do_list.py index bae85a8d7..6324728f0 100644 --- a/projects/ToDoList/to_do_list.py +++ b/projects/ToDoList/to_do_list.py @@ -1,85 +1,117 @@ -from pickle import dump, load +import telebot +from telebot import types + +bot = telebot.TeleBot("6540560961:AAEuobp6IGekPHPwSDxbxEEgI9LbPvYRgEc") + + +@bot.message_handler(commands=["start"]) +def start(message): + keyboard = types.ReplyKeyboardMarkup() + note = types.KeyboardButton("Добавить заметку") + deletenote = types.KeyboardButton("Удалить заметку") + editnote = types.KeyboardButton("Изменить заметку") + event = types.KeyboardButton("Добавить событие") + deletevent = types.KeyboardButton("Удалить событие") + editevent = types.KeyboardButton("Изменить событие") + check = types.KeyboardButton("Открыть текущие заметки/события") + keyboard.add(note, deletenote, editnote, event, deletevent, editevent, check) + bot.send_message( + message.chat.id, + f"{message.from_user.first_name}, я так рад, что вы снова сдесь! \U0001F601 \nВыберите, что бы вы хотели сделать:", + parse_mode="html", + reply_markup=keyboard, + ) + + +@bot.message_handler(func=lambda message: True) +def handle_button_click(message): + if (message.text.lower() == "добавить заметку") or ( + message.text.lower() == "/addn" + ): + addn(message) + elif (message.text.lower() == "добавить событие") or ( + message.text.lower() == "/adde" + ): + adde(message) + elif (message.text.lower() == "удалить заметку") or ( + message.text.lower() == "/deleten" + ): + deleten(message) + elif (message.text.lower() == "удалить событие") or ( + message.text.lower() == "/deletev" + ): + deletev(message) + elif (message.text.lower() == "изменить заметку") or ( + message.text.lower() == "/editn" + ): + editn(message) + elif (message.text.lower() == "изменить событие") or ( + message.text.lower() == "/edite" + ): + edite(message) + elif (message.text.lower() == "открыть текущие заметки/события") or ( + message.text.lower() == "/check" + ): + check(message) + elif message.text == "/help": + bot.send_message( + message.chat.id, + "С моей помощью вы легко сможете:\n\n" + "1) Добавить для себя любую заметку коммандой - | /addn |\n\n" + "2) Создать событие с напоминанием коммандой - | /adde |\n\n" + "3) Удалить любую заметку коммандой - | /deleten |\n\n" + "4) Удалить любое событие коммандой - | /deletev |\n\n" + "5) Изменить любую заметку коммандой - | /editn |\n\n" + "6) Изменить любое событие коммандой - | /edite |\n\n" + "7) Просматривать все свои заметки коммандой - | /check |\n\n", + parse_mode="html", + ) + elif message.text.isalpha(): + bot.send_message( + message.chat.id, + "Извини, но я не воспринимаю текст \U0001F972, тебе следует попробовать комманды!\n" + "Чтобы узнать, что я умею, введи комманду - | /help |", + ) + elif message.text.isdigit(): + bot.send_message( + message.chat.id, + "Извини, но я не воспринимаю цифры/числа \U0001F972, тебе следует попробовать комманды!\n" + "Чтобы узнать, что я умею, введи комманду - | /help |", + ) + else: + bot.send_message( + message.chat.id, + "Извини, но я воспринимаю только комманды \U0001F972\n" + "Чтобы узнать, что я умею, введи комманду - | /help |", + ) -def add_task(task): - todo_list.append(task) - print("Task added!") +def addn(message): + bot.send_message(message.chat.id, "Вы создали заметку") -def remove_task(task_num): - if 0 <= task_num < len(todo_list): - del todo_list[task_num] - print("Task removed!") - else: - print("Invalid task number!") +def adde(message): + bot.send_message(message.chat.id, "Вы создали событие") -def display_tasks(): - if not todo_list: # If list is empty - print("No tasks to display.") - else: - for index, task in enumerate(todo_list, start=1): - print(f"{index}. {task}") - - -def get_choice(): - while True: - try: - choice = int( - input( - "Type a number: 1. Adding a task, 2. Removing a task, 3. Displaying tasks, 4. Quit: " - ) - ) - if 1 <= choice <= 4: - return choice - else: - print("Invalid choice. Try again.") - except ValueError: - print("Please enter a number between 1 and 4.") - - -if __name__ == "__main__": - # Loading the pickle file into python as a list - try: - with open("todo.pickle", "rb+") as file_in: - todo_list = load(file_in) - except FileNotFoundError: - todo_list = [] - - print("Welcome to ToDo List!") - - while True: - user_choice = get_choice() - - # Adding a task - if user_choice == 1: - new_task = input("Type a new task: ") - add_task(new_task) - - # Removing a task - elif user_choice == 2: - if not todo_list: # If list is empty - print("No tasks to remove.") - else: - task_num = int(input("Enter the task number to delete: ")) - 1 - remove_task(task_num) - - # Displaying tasks - elif user_choice == 3: - display_tasks() - - # Quit - elif user_choice == 4: - # Dumping the list into a pickle file - with open("todo.pickle", "wb") as file_out: - dump(todo_list, file_out) - print("Goodbye!") - break - - -##################################### - -# CODE CONTRIBUTED BY: Ota Hina -# Dynamic funcionality added by : komsenapati - -##################################### +def deleten(message): + bot.send_message(message.chat.id, "Вы хотите удалить заметку") + + +def deletev(message): + bot.send_message(message.chat.id, "Вы удалили событие") + + +def editn(message): + bot.send_message(message.chat.id, "Вы хотите изменить заметку") + + +def edite(message): + bot.send_message(message.chat.id, "Вы хотите изменить событие") + + +def check(message): + bot.send_message(message.chat.id, "Вы хотите посмотреть список заметок/событий") + + +bot.polling(none_stop=True)