-
-
Notifications
You must be signed in to change notification settings - Fork 50.8k
ADD Message Encryption #14816
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
ADD Message Encryption #14816
Changes from all commits
9845f8f
35c17e8
a15dac9
9760475
4c06bd4
1614271
50f1584
ea10cec
1430a62
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| import random as ra | ||
| import string as str | ||
|
|
||
|
|
||
| def options(): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As there is no test file in this pull request nor any test function or class in the file Please provide return type hint for the function: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As there is no test file in this pull request nor any test function or class in the file Please provide return type hint for the function: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As there is no test file in this pull request nor any test function or class in the file Please provide return type hint for the function: |
||
| while True: | ||
| print("========== Welcome To Message Encryption ==========") | ||
| print("\t'1' For Encryption") | ||
| print("\t'2' For Decode") | ||
| try: | ||
| opt = int(input("Enter: ")) | ||
| if opt not in ("1", "2", 1, 2): | ||
| print("Choose Number Between '1','2'") | ||
| if opt == 1: | ||
| encrypt() | ||
| elif opt == 2: | ||
| decode() | ||
| except ValueError: | ||
| print("Enter Numbers Only") | ||
|
|
||
|
|
||
| def encrypt(): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please provide return type hint for the function: As there is no test file in this pull request nor any test function or class in the file There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As there is no test file in this pull request nor any test function or class in the file Please provide return type hint for the function: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As there is no test file in this pull request nor any test function or class in the file Please provide return type hint for the function: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As there is no test file in this pull request nor any test function or class in the file Please provide return type hint for the function: |
||
| x = input("Enter Your Message :") | ||
|
|
||
| if len(x) <= 3: | ||
| encrypt_key = input("Enter Your Key '1','4','7' :") | ||
|
|
||
| with open("User_Key.txt", "a+") as f: | ||
| f.write(f"{encrypt_key},{x}\n") | ||
| print(f"Successfully Encrypted: {x[::-1]}") | ||
|
|
||
| encrypt_key = input("Enter Your Key '1','4','7' :") | ||
|
|
||
| with open("User_Key.txt", "a") as f: | ||
| f.write(f"{encrypt_key},{x}\n") | ||
| shift = x[1:] + x[0] | ||
| prefix = "".join(ra.choice(str.ascii_letters) for _ in range(3)) | ||
| suffix = "".join(ra.choice(str.ascii_letters) for _ in range(3)) | ||
| message = prefix + shift + suffix | ||
| message = message.strip() | ||
| print(f"Successfully Encrypted: {message}") | ||
| return encrypt_key | ||
|
|
||
|
|
||
| def decode(): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please provide return type hint for the function: As there is no test file in this pull request nor any test function or class in the file There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As there is no test file in this pull request nor any test function or class in the file Please provide return type hint for the function: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As there is no test file in this pull request nor any test function or class in the file Please provide return type hint for the function: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As there is no test file in this pull request nor any test function or class in the file Please provide return type hint for the function: |
||
| with open("User_Key.txt", "r") as f: | ||
| user_message = input("Enter Message To Decode : ") | ||
| decode_key = input("Enter Your Key : ") | ||
| found = False | ||
|
|
||
| for line in f: | ||
| encrypt_key, x = line.strip().split(",") | ||
|
|
||
| if encrypt_key == decode_key: | ||
| if len(user_message) <= 3: | ||
| print(user_message[::-1]) | ||
| else: | ||
| x = user_message[3:-3] | ||
| x = x[-1] + x[:-1] | ||
| print(f"Message Decoded : {x}") | ||
|
|
||
| found = True | ||
| break | ||
|
|
||
| if not found: | ||
| print("Didn't Match :/") | ||
|
|
||
|
|
||
| options() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| import requests | ||
| import sys | ||
|
|
||
|
|
||
| def options(): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As there is no test file in this pull request nor any test function or class in the file Please provide return type hint for the function: |
||
|
|
||
| print("-" * 5, "Welcome To Daily News", "-" * 5) | ||
| print("Enter 1 For Headlines") | ||
| print("Enter 2 For Topic's") | ||
| print("Enter 3 For Geting News From Your API :)") | ||
| print("Enter 4 For Exit") | ||
|
|
||
| while True: | ||
| try: | ||
| choose = int(input("Choose :")) | ||
| match choose: | ||
| case 1: | ||
| return Fatch_News() | ||
| case 2: | ||
| return search() | ||
| case 3: | ||
| return Fatch_Key() | ||
| case 4: | ||
| return Exit() | ||
|
|
||
| except ValueError: | ||
| print("Enter Numbers Only") | ||
|
|
||
|
|
||
| def Fatch_Key(): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Variable and function names should follow the As there is no test file in this pull request nor any test function or class in the file Please provide return type hint for the function: |
||
|
|
||
| user_key = input("Enter Your API Key :") | ||
| return Fatch_News(user_key) | ||
|
|
||
|
|
||
| def search(): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As there is no test file in this pull request nor any test function or class in the file Please provide return type hint for the function: |
||
| pass | ||
|
|
||
|
|
||
| def Fatch_News(user_key=""): # Enter Your API Key Heare | ||
|
|
||
| url = f"https://newsapi.org/v2/everything?q=keyword&apiKey={user_key}" | ||
| request = requests.get(url) | ||
| data = request.json() | ||
|
|
||
| news = [] | ||
|
|
||
| for article in data["articles"]: | ||
| news.append( | ||
| { | ||
| "Title": article["title"], | ||
| "Author": article["author"], | ||
| "Description": article["description"], | ||
| } | ||
| ) | ||
|
|
||
| return news | ||
|
|
||
|
|
||
| def Exit(): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Variable and function names should follow the As there is no test file in this pull request nor any test function or class in the file Please provide return type hint for the function: |
||
|
|
||
| print("Thanks For Using PDF Tool Kit :)") | ||
| sys.exit() | ||
|
|
||
|
|
||
| # Run These Command To Get Info About Type Of Data We Are Dealing With | ||
| def Data_Info(): | ||
| """Tell Abut Type Of Data We Are Grtting From URL""" | ||
|
|
||
| url = "https://newsapi.org/v2/everything?q=keyword&apiKey=6495169f47154cfd83e9ac94ed500b0a" | ||
| request = requests.get(url) | ||
|
|
||
| data = request.json() | ||
|
|
||
| print(type(data)) | ||
| print(data.keys()) | ||
| print(data["articles"][0].keys()) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| options() | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide return type hint for the function:
options. If the function does not return a value, please provide the type hint as:def function() -> None:As there is no test file in this pull request nor any test function or class in the file
Projects/Message_Encryption.py, please provide doctest for the functionoptions