def dictReadSource(): readSource = {} readSource['webpsw'] = r'111111' readSource['rooturl'] = r'http://peter/zybxehr' readSource['host'] = r'peter' readSource['port'] = r'80' readSource['webname'] = r'sa' readSource['websalt'] = r'111111' if os.path.exists('./websource.json'): if os.path.getsize('./websource.json'): with open('./websource.json') as sourceFile: readSourceDict = json.load(sourceFile) decrypt_webtmpsalt = readSourceDict.get('websalt') print('decrypt_webtmpsalt: %s' % (decrypt_webtmpsalt)) decrypt_webtmpkey = prpcrypt(decrypt_webtmpsalt) decrypt_tmpwebpsw = readSourceDict.get('webpsw') print('decrypt_tmpwebpsw: %s' % (decrypt_tmpwebpsw)) decrypt_webpsw = decrypt_webtmpkey.decrypt(decrypt_tmpwebpsw) print('decrypt_webpsw: %s' % (decrypt_webpsw)) readSource['webpsw'] = decrypt_webpsw readSource['rooturl'] = readSourceDict.get('rooturl') readSource['host'] = readSourceDict.get('host') readSource['port'] = readSourceDict.get('port') readSource['webname'] = readSourceDict.get('webname') return readSource
def readConn(): dbConn = DBSource(r'peter', r'sa', r'111111', r'gaia') if os.path.exists('./sourcename.json'): if os.path.getsize('./sourcename.json'): with open('./sourcename.json') as connFile: readConnDict = json.load(connFile) decrypt_tmpkey = prpcrypt(readConnDict['dbsalt']) decrypt_psw = decrypt_tmpkey.decrypt(readConnDict['dbpsw']) dbConn = DBSource(readConnDict['servername'], readConnDict['dbusername'], decrypt_psw, readConnDict['dbname']) return dbConn
def saveNewSource(self): connInfo['rooturl'] = str(self.entry_rooturl_var.get()) connInfo['host'] = str(self.entry_host_var.get()) connInfo['port'] = str(self.entry_port_var.get()) connInfo['webname'] = str(self.entry_webname_var.get()) connInfo['webpsw'] = str(self.entry_webpsw_var.get()) tempkey1 = randomString(16) pc1 = prpcrypt(tempkey1) encryptedKey1 = pc1.encrypt(connInfo['webpsw']) connInfo['webpsw'] = str(encryptedKey1.decode()) connInfo['websalt'] = str(tempkey1) with open('websource.json', 'w+') as file_object: json.dump(connInfo, file_object) mb.showinfo( '您已经成功更新站点源', '您所更新的站点信息如下:根地址:%s;主机地址:%s;端口:%s;登录账户:%s;' % (connInfo['rooturl'], connInfo['host'], connInfo['port'], connInfo['webname'])) global ehrsource ehrsource = dictReadSource()
def saveNewConnecttion(self): connInfo['servername'] = str(self.entry_servername_var.get()) connInfo['dbusername'] = str(self.entry_dbusername_var.get()) connInfo['dbpsw'] = self.entry_dbpsw_var.get() connInfo['dbname'] = str(self.entry_dbname_var.get()) connInfo['sourcename'] = str(self.entry_sourcename_var.get()) tempkey = randomString(16) pc = prpcrypt(tempkey) encryptedKey = pc.encrypt(connInfo['dbpsw']) connInfo['dbpsw'] = str(encryptedKey.decode()) connInfo['dbsalt'] = str(tempkey) with open('sourcename.json', 'w+') as file_object: json.dump(connInfo, file_object) mb.showinfo( '您已经成功更新数据库链接', '您所更新的数据库链接信息如下:服务器名称:%s;数据库名称:%s;用户名:%s;' % (connInfo['servername'], connInfo['dbname'], connInfo['dbusername'])) global ehr ehr = readConn()