def checkInfo(self): '''Checks that all the information fields are filled out and valid. Loads the required information and passes it for encrypted image creation.''' common.turnBlack(self.missingInfo) self.missingInfo = [] # Checks that a public key image has been selected and the relevant information has been filled in. if self.pkSelectGroup.checkedId() == -1: self.missingInfo.append(self.pkLabel) elif self.pkSelectGroup.checkedId() == 1 and self.pkFromHDText.text() == '': self.missingInfo.append(self.pkFromHD) elif self.pkSelectGroup.checkedId() == 2 and self.pkFromInternetText.text() == '': self.missingInfo.append(self.pkFromInternet) # Checks that a encrypted image has been selected and the relevant information has been filled in. if self.encSelectGroup.checkedId() == -1: self.missingInfo.append(self.encLabel) elif self.encSelectGroup.checkedId() == 1 and self.encFromHDText.text() == '': self.missingInfo.append(self.encFromHD) elif self.encSelectGroup.checkedId() == 2 and self.encFromInternetText.text() == '': self.missingInfo.append(self.encFromInternet) # Checks that message method has been selected and the relevant information has been filled in. if self.msgSelectGroup.checkedId() == -1: self.missingInfo.append(self.msgLabel) elif self.msgSelectGroup.checkedId() == 1 and self.msgFromHDText.text() == '': self.missingInfo.append(self.msgFromHD) elif self.msgSelectGroup.checkedId() == 2 and self.msgInputText.toPlainText() == '': self.missingInfo.append(self.msgInput) # Turns missing information labels red, or attempts to load the images if we have no missing information. if self.missingInfo != []: common.turnRed(self.missingInfo) common.popUpText(self, 'Error: Missing information. Empty fields have been highlighted.', 'Error') else: self.pkImageLoad()
def pkImageLoad(self): '''Loads the public key image ''' # Public Key Image from Hard Drive if self.pkSelectGroup.checkedId() == 1: try: self.pkImage = Image.open(self.pkFromHDText.text()) self.pkInformation() except IOError: self.missingInfo.append(self.pkFromHD) common.turnRed(self.missingInfo) common.popUpText(self, 'Error: Cannot open public key image. Please try another image.', 'Error') # Public Key Image from Internet elif self.pkSelectGroup.checkedId() == 2: try: self.urlPKImage = cStringIO.StringIO(urllib.urlopen(self.pkFromInternetText.text()).read()) self.pkImage = Image.open(self.urlPKImage) self.pkInformation() except IOError: self.missingInfo.append(self.pkFromInternet) common.turnRed(self.missingInfo) common.popUpText(self, 'Error: Cannot open public key image. Please verify that the website address is correct or try another image.', 'Error')
def setHiddenMsg(self): '''Loads the message to encrypted and conceal.''' # Message from txt file if self.msgSelectGroup.checkedId() == 1: try: msgFile = open(self.msgFromHDText.text()) self.hiddenMsg = msgFile.read() msgFile.close() self.createEncImg() except IOError: self.missingInfo.append(self.msgFromHD) common.turnRed(self.missingInfo) common.popUpText(self, 'Error: Cannot get a message from the text file. Please select another text file.', 'Error') except: self.missingInfo.append(self.msgFromHD) common.turnRed(self.missingInfo) common.popUpText(self, 'Error: Cannot get a message from the text file. Please select another text file.', 'Error') raise # Message from GUI textbox elif self.msgSelectGroup.checkedId() == 2: self.hiddenMsg = self.msgInputText.toPlainText() self.createEncImg()
def encBaseImageLoad(self): '''Loads the public key image ''' # Image from Hard Drive if self.encSelectGroup.checkedId() == 1: try: self.encBaseImage = Image.open(self.encFromHDText.text()) self.setHiddenMsg() except IOError: self.missingInfo.append(self.encFromHD) common.turnRed(self.missingInfo) common.popUpText(self, 'Error: Cannot open encrypted image. Please try another image.', 'Error') # Image from the Internet elif self.encSelectGroup.checkedId() == 2: try: self.urlEncImage = cStringIO.StringIO(urllib.urlopen(self.encFromInternetText.text()).read()) self.encBaseImage = Image.open(self.urlEncImage) self.setHiddenMsg() except IOError: self.missingInfo.append(self.encFromInternet) common.turnRed(self.missingInfo) common.popUpText(self, 'Error: Cannot open encrypted image. Please verify that the website address is correct or try another image.', 'Error')
def checkInfo(self): '''Checks that all the information fields are filled out and valid. Loads the required information and passes it for encrypted image creation.''' common.turnBlack(self.missingInfo) self.missingInfo = [] # Checks that an encrypted image is selected and relevant information is present. if self.encSelectGroup.checkedId() == -1: self.missingInfo.append(self.encLabel) elif self.encSelectGroup.checkedId() == 1 and self.encFromHDText.text() == '': self.missingInfo.append(self.encFromHD) elif self.encSelectGroup.checkedId() == 2 and self.encFromInternetText.text() == '': self.missingInfo.append(self.encFromInternet) # Checks that a password has been entered. if self.passwordText.text() == '': self.missingInfo.append(self.inputPasswordLabel) self.missingInfo.append(self.passwordLabel) # Turns missing information labels red, or attempts to load the images if we have no missing information. if self.missingInfo != []: common.turnRed(self.missingInfo) common.popUpText(self, 'Error: Missing information. Empty fields have been highlighted.', 'Error') else: self.encImageLoad()
def checkInfo(self): '''Checks that all the information fields are filled out. Creates the public key image once information is complete.''' common.turnBlack(self.missingInfo) self.missingInfo = [] # Check that a curve has been selected. if self.curveGroup.checkedId() == -1: self.missingInfo.append(self.curveLabel) # Check that an image location has been selected and location information is present. if self.selectGroup.checkedId() == -1: self.missingInfo.append(self.selectImageLabel) elif self.selectGroup.checkedId() == 1 and self.fromHDText.text() == '': self.missingInfo.append(self.fromHD) elif self.selectGroup.checkedId() == 2 and self.fromInternetText.text() == '': self.missingInfo.append(self.fromInternet) # Check that a password is filled in and that the two password fields match. if self.passwordText.text() == '': self.missingInfo.append(self.createPasswordLabel) elif self.passwordText.text() != self.cPasswordText.text(): self.missingInfo.append(self.passwordLabel) self.missingInfo.append(self.cPasswordLabel) # Turns missing information labels red, or attempts to load the image if we have no missing information. if self.missingInfo != []: common.turnRed(self.missingInfo) common.popUpText(self, 'Error: Missing information. Empty fields have been highlighted.', 'Error') else: if self.selectGroup.checkedId() == 1: try: self.baseImage = Image.open(self.fromHDText.text()) self.createPK() except IOError: self.missingInfo.append(self.fromHD) common.turnRed(self.missingInfo) common.popUpText(self,'Error: Cannot open image. Please try another image.', 'Error') elif self.selectGroup.checkedId() == 2: try: self.urlImage = cStringIO.StringIO(urllib.urlopen(self.fromInternetText.text()).read()) self.baseImage = Image.open(self.urlImage) self.createPK() except IOError: self.missingInfo.append(self.fromInternet) common.turnRed(self.missingInfo) common.popUpText(self,'Error: Cannot open image. Please verify that the website address is correct or try another image.', 'Error')