From 2054c097049c1046885949eb9937cf43fbfe9d85 Mon Sep 17 00:00:00 2001 From: esy Date: Wed, 10 Jun 2020 17:49:19 +0200 Subject: [PATCH] Ajout pour correction checksum de MT --- InterfaceQT4/editorSsIhm.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/InterfaceQT4/editorSsIhm.py b/InterfaceQT4/editorSsIhm.py index 69bd9d6b..8d0bb0a3 100644 --- a/InterfaceQT4/editorSsIhm.py +++ b/InterfaceQT4/editorSsIhm.py @@ -481,15 +481,23 @@ class JDCEditorSsIhm : def getChecksum(self,texte): #---------------------------# try : + import haslib newtexte=texte.replace('"','\\"') - commande='echo "'+newtexte+'"|md5sum' - a=os.popen(commande) - checksum=a.read() - a.close() - except : - checksum='Fichier trop long \n' - ligne="#CHECKSUM:"+checksum[0:-1]+":FIN CHECKSUM" - return ligne + hash_checksum = hashlib.md5() + hash_checksum.update(newtexte.encode('utf-8')) + checksum = hash_checksum.hexdigest() + ligne = ligne="#CHECKSUM:"+checksum+":FIN CHECKSUM" + except : + try : + newtexte=texte.replace('"','\\"') + commande='echo "'+newtexte+'"|md5sum' + a=os.popen(commande) + checksum=a.read() + a.close() + except : + checksum='Fichier trop long \n' + ligne="#CHECKSUM:"+checksum[0:-1]+":FIN CHECKSUM" + return ligne #----------------------# def getDico(self): -- 2.39.2