I am having some difficulty with commenting my code for a python password cracking application, I have created. I have commented on the majority of the code however was wondering if anyone could suggest anymore comments I need as my instructor is really stick on me commenting my code.
Here is my code:
import time import string #Variables max_attempts = 999999999 #the number of attempts the system makes for a brute-force attack start = time.time() #monitors the time length chars = list(string.printable) #all the possible ascii characters which the system uses to determine the password base = len(chars) #the base for conversion n = 0 #number of attempts solved = False password = input("Enter your password:") #the feature which allows the user to enter in their chosen password print(chars) #record of previous password attempts # converts number N base 10 to a list of digits base b def numberToBase(n, b): digits = [] while n: # takes n and the finds the modulus, the remainder of n % b digits.append(int(n % b)) # then it will append that to a list n //= b # following on it will then divide n into b return digits[::-1] #returns those digits into reverse order from -1, the end to the beginning # checks if the user has inputted empty text/numbers/symbols if password == '': print('Your password is empty') solved = True elif password == chars[n]: print('Your password is ' + chars[n]) solved = True else: n = 1 #Begins systematically checking the password if not solved: while n < max_attempts: list = numberToBase(n, base) print(list) word = '' for c in list: #loop through each of the characters in the list word += str(chars[c]) #adds the characters from the list to a word print(word) if password == word: #checks if the password equals to the word the system has generated solved = True # if the generation is correct the password will then commence to print statements print('***Results***') print('Password: ' + word) print('Attempts: ' + str(n)) print('Time: ' + str((time.time() - start)) + ' sec') break #stops the loop else: n += 1 #however if the password generation isn't correct, we increment with n # the password is beyond max_attempts if not solved: print('Unsolved after ' + str(n) + ' attempts!')