Skip to content

Commit

Permalink
style: format code with autopep8
Browse files Browse the repository at this point in the history
Format code with autopep8

This commit fixes the style issues introduced in 9ba8bac according to the output
from Autopep8.

Details: https://app.deepsource.com/gh/avinashkranjan/Amazing-Python-Scripts/transform/4d390bc4-407f-470f-8d11-c3519be94a4e/
  • Loading branch information
deepsource-autofix[bot] authored Jul 21, 2023
1 parent 225b071 commit 743ad7b
Show file tree
Hide file tree
Showing 357 changed files with 7,203 additions and 5,941 deletions.
50 changes: 33 additions & 17 deletions 9_Typesof_Hash_Craker/9_Types_of_Hash_Cracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,24 @@ class Cracker(object):
ALPHA_MIXED = (string.ascii_lowercase, string.ascii_uppercase)
PUNCTUATION = (string.punctuation,)
NUMERIC = (''.join(map(str, range(0, 10))),)
ALPHA_LOWER_NUMERIC = (string.ascii_lowercase, ''.join(map(str, range(0, 10))))
ALPHA_UPPER_NUMERIC = (string.ascii_uppercase, ''.join(map(str, range(0, 10))))
ALPHA_MIXED_NUMERIC = (string.ascii_lowercase, string.ascii_uppercase, ''.join(map(str, range(0, 10))))
ALPHA_LOWER_NUMERIC = (string.ascii_lowercase,
''.join(map(str, range(0, 10))))
ALPHA_UPPER_NUMERIC = (string.ascii_uppercase,
''.join(map(str, range(0, 10))))
ALPHA_MIXED_NUMERIC = (
string.ascii_lowercase, string.ascii_uppercase, ''.join(map(str, range(0, 10))))
ALPHA_LOWER_PUNCTUATION = (string.ascii_lowercase, string.punctuation)
ALPHA_UPPER_PUNCTUATION = (string.ascii_uppercase, string.punctuation)
ALPHA_MIXED_PUNCTUATION = (string.ascii_lowercase, string.ascii_uppercase, string.punctuation)
ALPHA_MIXED_PUNCTUATION = (
string.ascii_lowercase, string.ascii_uppercase, string.punctuation)
NUMERIC_PUNCTUATION = (''.join(map(str, range(0, 10))), string.punctuation)
ALPHA_LOWER_NUMERIC_PUNCTUATION = (string.ascii_lowercase, ''.join(map(str, range(0, 10))), string.punctuation)
ALPHA_UPPER_NUMERIC_PUNCTUATION = (string.ascii_uppercase, ''.join(map(str, range(0, 10))), string.punctuation)
ALPHA_LOWER_NUMERIC_PUNCTUATION = (string.ascii_lowercase, ''.join(
map(str, range(0, 10))), string.punctuation)
ALPHA_UPPER_NUMERIC_PUNCTUATION = (string.ascii_uppercase, ''.join(
map(str, range(0, 10))), string.punctuation)
ALPHA_MIXED_NUMERIC_PUNCTUATION = (
string.ascii_lowercase, string.ascii_uppercase, ''.join(map(str, range(0, 10))), string.punctuation
string.ascii_lowercase, string.ascii_uppercase, ''.join(
map(str, range(0, 10))), string.punctuation
)

def __init__(self, hash_type, hash, charset, progress_interval):
Expand Down Expand Up @@ -90,7 +97,8 @@ def __attack(self, q, max_length):
hasher.update(hash_fn(value))
if self.__hash == hasher.hexdigest():
q.put("FOUND")
q.put("{}Match found! Password is {}{}".format(os.linesep, value, os.linesep))
q.put("{}Match found! Password is {}{}".format(
os.linesep, value, os.linesep))
self.stop_reporting_progress()
return

Expand All @@ -110,7 +118,8 @@ def work(work_q, done_q, max_length):
obj.__attack(done_q, max_length)

def start_reporting_progress(self):
self.__progress_timer = threading.Timer(self.__progress_interval, self.start_reporting_progress)
self.__progress_timer = threading.Timer(
self.__progress_interval, self.start_reporting_progress)
self.__progress_timer.start()
print(
f"Character set: {self.__charset}, iteration: {self.__curr_iter}, trying: {self.__curr_val}, hashes/sec: {self.__curr_iter - self.__prev_iter}",
Expand All @@ -119,7 +128,8 @@ def start_reporting_progress(self):

def stop_reporting_progress(self):
self.__progress_timer.cancel()
print(f"Finished character set {self.__charset} after {self.__curr_iter} iterations", flush=True)
print(
f"Finished character set {self.__charset} after {self.__curr_iter} iterations", flush=True)


if __name__ == "__main__":
Expand Down Expand Up @@ -153,7 +163,8 @@ def stop_reporting_progress(self):
"09": "SHA512"
}

prompt = "Specify the character set to use:{}{}".format(os.linesep, os.linesep)
prompt = "Specify the character set to use:{}{}".format(
os.linesep, os.linesep)
for key, value in sorted(character_sets.items()):
prompt += "{}. {}{}".format(key, ''.join(value), os.linesep)

Expand All @@ -162,12 +173,14 @@ def stop_reporting_progress(self):
charset = input(prompt).zfill(2)
selected_charset = character_sets[charset]
except KeyError:
print("{}Please select a valid character set{}".format(os.linesep, os.linesep))
print("{}Please select a valid character set{}".format(
os.linesep, os.linesep))
continue
else:
break

prompt = "{}Specify the maximum possible length of the password: ".format(os.linesep)
prompt = "{}Specify the maximum possible length of the password: ".format(
os.linesep)

while True:
try:
Expand Down Expand Up @@ -197,7 +210,8 @@ def stop_reporting_progress(self):
try:
user_hash = input(prompt)
except ValueError:
print("{}Something is wrong with the format of the hash. Please enter a valid hash".format(os.linesep))
print("{}Something is wrong with the format of the hash. Please enter a valid hash".format(
os.linesep))
continue
else:
break
Expand All @@ -207,7 +221,8 @@ def stop_reporting_progress(self):
work_queue = multiprocessing.Queue()
done_queue = multiprocessing.Queue()
progress_interval = 3
cracker = Cracker(hash_type.lower(), user_hash.lower(), ''.join(selected_charset), progress_interval)
cracker = Cracker(hash_type.lower(), user_hash.lower(),
''.join(selected_charset), progress_interval)
start_time = time.time()
p = multiprocessing.Process(target=Cracker.work,
args=(work_queue, done_queue, password_length))
Expand All @@ -218,7 +233,8 @@ def stop_reporting_progress(self):
if len(selected_charset) > 1:
for i in range(len(selected_charset)):
progress_interval += .2
cracker = Cracker(hash_type.lower(), user_hash.lower(), selected_charset[i], progress_interval)
cracker = Cracker(hash_type.lower(), user_hash.lower(),
selected_charset[i], progress_interval)
p = multiprocessing.Process(target=Cracker.work,
args=(work_queue, done_queue, password_length))
processes.append(p)
Expand All @@ -241,4 +257,4 @@ def stop_reporting_progress(self):
print("{}No matches found{}".format(os.linesep, os.linesep))
break

print("Took {} seconds".format(time.time() - start_time))
print("Took {} seconds".format(time.time() - start_time))
14 changes: 7 additions & 7 deletions AI Calculator/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
# naming the ChatBot calculator
# using mathematical evaluation logic
# the calculator AI will not learn with the user input
Bot = ChatBot(name = 'Calculator',
read_only = True,
logic_adapters = ["chatterbot.logic.MathematicalEvaluation"],
storage_adapter = "chatterbot.storage.SQLStorageAdapter")
Bot = ChatBot(name='Calculator',
read_only=True,
logic_adapters=["chatterbot.logic.MathematicalEvaluation"],
storage_adapter="chatterbot.storage.SQLStorageAdapter")


# clear the screen and start the calculator
print('\033c')
print("Hello, I am a calculator. How may I help you?")
while (True):
# take the input from the user
user_input = input("me: ")
# check if the user has typed quit to exit the prgram

# check if the user has typed quit to exit the prgram
if user_input.lower() == 'quit':
print("Exiting")
break
Expand Down
20 changes: 11 additions & 9 deletions AI Chat Bot/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,47 +9,49 @@


headers = {
"content-type": "application/json",
"X-RapidAPI-Key": "OUR API KEY",
"X-RapidAPI-Host": "simple-chatgpt-api.p.rapidapi.com"
"content-type": "application/json",
"X-RapidAPI-Key": "OUR API KEY",
"X-RapidAPI-Host": "simple-chatgpt-api.p.rapidapi.com"
}


def animate():
for c in itertools.cycle(['|', '/', '-', '\\']):
if done:
break
sys.stdout.write('\r' + c)
sys.stdout.flush()
time.sleep(0.1)

# Clear the console output
sys.stdout.write('\r')
sys.stdout.flush()


def ask(question):
payload = { "question": question }
payload = {"question": question}
response = requests.post(url, json=payload, headers=headers)
return response.json().get("answer")


if __name__ == "__main__":
print(pyfiglet.figlet_format("AI Chat BOT"))
print("Enter the question to ask:")
print()
while True:
# print("/>> ", end="")
question = str(input(">> "))
if(question == 'q'):
if (question == 'q'):
print(">> Bye! Thanks for Using...")
break
# loading
done = False
#here is the animation
# here is the animation
t = threading.Thread(target=animate)
t.start()
answer = ask(question)
time.sleep(5)
done = True
t.join()
print(">> ",answer)
print(">> ", answer)
print()

2 changes: 2 additions & 0 deletions AI TicTacToe/src/TicTacToe.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import random


def display_board(board):
print('-------------')
print('| ' + board[7] + ' | ' + board[8] + ' | ' + board[9] + ' |')
Expand Down Expand Up @@ -110,5 +111,6 @@ def play_tic_tac_toe():
print('Thank you for playing.')
break


# Start the game
play_tic_tac_toe()
Loading

0 comments on commit 743ad7b

Please sign in to comment.