def changeMasterPwd(self, newPwd): oldPwd = config.getMasterPwd() conn = self.getConnection() mDao = MasterPwdDao(conn) pDao = PwdDao(conn) # 1st re-encrypt all passwords with the new master password accountList = pDao.getAllPwd() currentDate = unicode(datetime.datetime.today()) for account in accountList: dePwd = util.decrypt(oldPwd, account.pwd) enPwd = util.encrypt(newPwd, dePwd) if account.secret: deSecret = util.decrypt(oldPwd, account.secret) enSecret = util.encrypt(newPwd, deSecret) else: enSecret = '' deUsername = util.decrypt(oldPwd, account.username) enUsername = util.encrypt(newPwd, deUsername) pDao.updateAccount(account.id, account.title, account.description, enUsername, enPwd, enSecret, currentDate) # 2nd get md5 of new master password, update the masterpassword table newMD5String = util.md5Encoding(newPwd) mDao.updateMasterPwd(newMD5String) # 3rd update master password in config module config.setMasterPwd(newPwd) conn.commit() conn.close()
def authenticate(self): mFunc = MasterFunc() self.setLabelText() self.pwd.setFocus() var = self.exec_() if var: inPwd = unicode(self.pwd.text()) if not (mFunc.authenticate(inPwd)): myGui.showErrorDialog(myGui.ERR_LOGIN) global RETRY if RETRY > 1: RETRY -= 1 self.setLabelText() self.pwd.clear() return self.authenticate() else: return False else: config.setMasterPwd(inPwd) return True else: return False