def hide(): msg = "" passwd = "" inputImg = "" outputDir = "" msg = messageEntry.get('1.0', END) msg = msg[:-1] if passwordState.get(): passwd = passwordEntry.get() inputImg = printIImg["text"] outputDir = printOImg["text"] if (msg == "") or (passwordState.get() and (passwd == "")) or (inputImg == "") or (outputDir == ""): messagebox.showerror("Error", "Incomplete information....") textMsgRadio.invoke() else: if passwordState.get(): en = Encryption.Encrypt(msg, passwd) msg = en.encryptMessage() print(msg) sn = Steganography.Steg() sn.hide(inputImg, outputDir, msg) messagebox.showinfo("Successfull", "Information is hidden....") resetH()
def retrieve(): msgR = "" passwdR = "" inputImgR = "" inputImgR = printIImgR["text"] if passwordStateR.get(): passwdR = passwordEntryR.get() if (passwordStateR.get() and (passwdR == "")) or (inputImgR == ""): messagebox.showerror("Error", "Incomplete information....") else: sn = Steganography.Steg() try: msgR = sn.retr(inputImgR) if passwordStateR.get(): en = Encryption.Encrypt(msgR, passwdR) msgR = en.decryptMessage() if (msgR == "!-)=~"): messagebox.showarning("Warning", "Incorrect password or image....") else: messageEntryR.delete('1.0', END) messageEntryR.insert(tk.END, msgR) messagebox.showinfo("Successfull", "Information is retrieved....") except: messagebox.showerror("Error", "Incorrect password or image....") resetR()
def checkdetails(): username = input("please enter your username: \n") password = input("please enter your password: \n") filename = "details.csv" os.system("clear") EncryptFunction.Decrypt(filename+".aes") #reads csv file with open(filename, "r") as details_file: continueTo = False reader = csv.reader(details_file, delimiter=",") #reads each line which has a username and password and compares to use input for line in reader: if username == line[0] and password == line[1]: continueTo = True os.remove("details.csv") if continueTo == False: tryAgain = input("incorrect details, try again yes(1) or no(2) \n") if tryAgain == '1': checkdetails() else: EncryptFunction.Encrypt(filename) os.remove(filename) elif continueTo == True: if "admin" in username: os.system("clear") AdminPanel(username, filename) else: os.system("clear") UserPanel(username)
def Edit(filename): #decrypts the csv file so the user can delete an account bufferSize = 64 * 1024 password = input("Enter the password for the file to decrypt it: \n") pyAesCrypt.decryptFile(filename + ".aes", filename, password, bufferSize) os.remove(filename + ".aes") #prompts user to choose what they would like to edit passOrUser = input( "Would you like to edit a username(1), password(2) or both(3)") #reads csv file data into a pandas data frame df = pd.read_csv(filename) print(df) if int(passOrUser) == 1: editUsername = input("Enter the username you want to edit: \n") newUsername = input("Enter the new username: \n") #stores the index of the current username index = df.loc[df['username'] == editUsername].index[0] #stores current password password = df.loc[index, 'password'] #creates a new row with index, new username and current password newRow = df.loc[index] = [newUsername, password] #adds the row to the dataframe at a specific index df.append(newRow) #stores dataframe in the csv file df.to_csv(filename, index=False) #code is the same for each condition but structured slightly differently for a different purpose elif int(passOrUser) == 2: editPassword = input("Enter the password you want to edit: \n") newPassword = input("Enter the new password: \n") index = df.loc[df['password'] == editPassword].index[0] username = df.loc[index, 'username'] newRow = df.loc[index] = [username, newPassword] df.append(newRow) df.to_csv(filename, index=False) elif int(passOrUser) == 3: editUsername = input("Enter the username you want to edit: \n") newUsername = input("Enter the new username: \n") newPassword = input("Enter the new password: \n") index = df.loc[df['username'] == editUsername].index[0] newRow = df.loc[index] = [newUsername, newPassword] df.append(newRow) df.to_csv(filename, index=False) #re-encrypts the csv file EncryptionFunction.Encrypt("details.csv") os.remove(filename) DoAgain()
def Add(filename): #decrypts the csv file so the user can delete an account bufferSize = 64 * 1024 password = input("Enter the password for the file to decrypt it: \n") pyAesCrypt.decryptFile(filename + ".aes", filename, password, bufferSize) os.remove(filename + ".aes") #prompts user to enter the username and password they want to add to the csv file username = input("Enter username you want to add: \n") password = input("Enter password you want to add: \n") csvFile = open(filename, "a") #appends the username and password with a delimter to the end of the csv file csvFile.write(username + "," + password) csvFile.close() #re-encrypts the csv file EncryptionFunction.Encrypt("details.csv") os.remove(filename) DoAgain()
def Delete(filename): #decrypts the csv file so the user can delete an account bufferSize = 64 * 1024 password = input("Enter the password for the file to decrypt it: \n") pyAesCrypt.decryptFile(filename + ".aes", filename, password, bufferSize) os.remove(filename + ".aes") delUserName = input( "Enter the username of the account you want to delete: \n") #reads the csv file into a pandas data frame df = pd.read_csv(filename) #checks whether the column "username" contains the username provided by the user #if it contains it, it removes that line then dumps the dataframe back into the csv file df = df[~df["username"].str.contains(delUserName, na=False)].to_csv( 'details.csv', index=False) # calls encryption function to re-encrypt the csv file EncryptionFunction.Encrypt("details.csv") os.remove(filename) DoAgain()
count = 1 message = "" #Run the algorithm until all encoded text is decoded for i in range(len(s)): first = True c = 1 count = 1 while c != 0: #if first number just preform mod 256 if first: c = s[i] % 256 message += chr(c) first = False #if not the first number apply the rest of the algorithm else: c = (s[i] - c) // (256**count) % 256 if c == 0: break message += chr(c) count += 1 #return the decrpyted message return (message) KeySetup.GenerateKeys() Encryption.Encrypt() cipher = Decrypt() print(Decode(cipher))