#!/usr/bin/env python3 """Copydev Imposing Tool — Point d'entree.""" import sys import os import hashlib # Ajouter le repertoire racine au path sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) from PyQt6.QtWidgets import QApplication, QInputDialog, QMessageBox, QLineEdit # Hash SHA-256 du mot de passe — jamais en clair dans le code _PASSWORD_HASH = "f3dd6962a99a2fe2e03cd8e5cfa7dafb12570bdcca1b6590e27d95dcccdf1f58" def _hash_password(pwd): return hashlib.sha256(pwd.encode("utf-8")).hexdigest() def _check_auth(): """Demander le mot de passe au lancement.""" max_attempts = 3 for attempt in range(max_attempts): pwd, ok = QInputDialog.getText( None, "Copydev Imposing Tool", f"Mot de passe requis ({max_attempts - attempt} essai(s) restant(s)) :", QLineEdit.EchoMode.Password, ) if not ok: return False if _hash_password(pwd) == _PASSWORD_HASH: return True if attempt < max_attempts - 1: QMessageBox.warning(None, "Erreur", "Mot de passe incorrect.") QMessageBox.critical(None, "Acces refuse", "Trop de tentatives. L'application va se fermer.") return False def main(): app = QApplication(sys.argv) app.setApplicationName("Copydev Imposing Tool") app.setOrganizationName("Copydev") if not _check_auth(): sys.exit(1) from app.main_window import MainWindow window = MainWindow() window.show() sys.exit(app.exec()) if __name__ == "__main__": main()