def decodeMethod(self): index = self.cipherTypes.currentIndex() text = encode(self.textInput.text()) key = self.keyInput.text() if index==0: if not key.isnumeric(): self.popError('Specify an Integer Key please') else: ciphertext = text.decode_caesar(int(key)) elif index==1: if not key.isalpha(): self.popError('Specify a valid KeyWord please') else: ciphertext = text.decode_vigenere(key) elif index==2: if not key.isnumeric(): self.popError('Specify an Integer Key please') else: ciphertext = text.decode_matrix(int(key)) elif index==3: if not key.isalpha(): self.popError('Specify a valid KeyWord please') else: ciphertext = text.decode_porta(key) elif index==4: if not key.isalnum() or not len(key) == 36: self.popError('Specify a valid (36 digit) HashKey please') else: ciphertext = text.decode_ADFGVX(key) else: ciphertext = '' try: self.textOut.setText(ciphertext) except: pass
import hashing import pandas as pd # This test works on hashing.py, using the program to add or modify a row to the csv file storing user information # Replace these values with the desired information to be implemented into the CSV file: row = 1 # Indices for rows start at 1 name = "Will Greene" username = "******" password = "******" email = "*****@*****.**" role = "P" # Can be S for student, or P for Professor # Replace path below with the current location of the Users.csv file loginInfo = pd.read_csv("C:/Users/benha/Documents/CMSC 447 Project/Users.csv") loginInfo.at[row, 'Name'] = name loginInfo.at[row, 'Role'] = role loginInfo.at[row, 'Username'] = username loginInfo.at[ row, 'Password'] = password # This is done so that passwords can be found by developers for use in # Testing. This column will be removed in the final iteration. loginInfo.at[row, 'Email'] = email hashing.encode(password, row, loginInfo) # Open the CSV file to see your output!
def addStudent(course, section, email, firstName, lastName, userName): # Checks if the email currently exists in the system userExists = loginInfo['Email'].isin([email]).any() if isinstance(firstName, int) or isinstance(lastName, int): return -1 # If the user exists, attempts to add the student to the system if userExists: # Obtains the current class lists and sections of the user rowNumber = int(loginInfo[loginInfo['Email'] == email].index[0]) classes = str(loginInfo.at[rowNumber, 'Classes']) sections = str(loginInfo.at[rowNumber, 'Sections']) classes = list(classes.split(",")) sections = list(sections.split(",")) # If the user had no classes, clears the list if "NA" in classes: classes.remove("NA") if "NA" in sections: sections.remove("NA") # If the user had one class, convers the class and section numbers from floats to integers for i in range(len(classes)): if classes[i].endswith('.0'): classes[i] = classes[i].replace('.0', '') if sections[i].endswith('.0'): sections[i] = sections[i].replace('.0', '') # Ensures that the section and class are not duplicated for i in range(len(classes)): if str(classes[i]) == str(course): if str(sections[i]) == str(section): return -2 # Adds the new class to the list, and saves it to the file classes.append(str(course)) classes = ",".join(classes) loginInfo.at[rowNumber, 'Classes'] = classes # Adds the new section to the list, and saves it to the file sections.append(str(section)) sections = ",".join(sections) loginInfo.at[rowNumber, 'Sections'] = sections # Saves the csv loginInfo.to_csv("C:/Users/benha/Documents/CMSC 447 Project/Users.csv", mode='w', index=False) return 1 else: password = randint(10000000, 99999999) name = firstName + " " + lastName loginInfo.loc[len(loginInfo.index)] = [ name, 'S', userName, str(password), 1, email, course, section ] rowNumber = int(loginInfo[loginInfo['Email'] == email].index[0]) hashing.encode(str(password), rowNumber, loginInfo) return 1 return -1