我是這個模塊的新手,所以如果我的問題聽起來很愚蠢,請原諒我。我正在創建一個應用程序并使用 cryptography.fernet 來加密 MySQL 憑據。例如,如果我加密并得到這個from cryptography.fernet import Fernetkey = b'PCHl_MjGyEyBxLYha3S-cWg_SDDmjT4YYaKYh4Z7Yug='cipher_suite = Fernet(key)ciphered_text = cipher_suite.encrypt(b"SQLShack@DemoPass") print(ciphered_text)如果我必須像下面這樣解密密碼,如何防止最終用戶簡單地打印出密碼?他們可以只打印 print(unciphered_text)。將密碼保存到數據庫也達不到目的,因為我的密碼是用于數據庫的。感謝您提前提供的幫助。key = b'PCHl_MjGyEyBxLYha3S-cWg_SDDmjT4YYaKYh4Z7Yug='cipher_suite = Fernet(key)ciphered_text = b'gAAAAABd_jcLWEz-fIBt3y2P3IoB3jGdbNnSzeSINZ8BomP9DrKIX2YF4pMLkMCvCxLshmKgKXk7np42xop6QIaiawbhjGayMU0UrbTeUX-6XA8zmo55vwA='unciphered_text = (cipher_suite.decrypt(ciphered_text))我只想在我的代碼中這樣做try: engine = create_engine('mysql+mysqlconnector://root:encrypted_password@encrypted_host:3306/encrypted_databsed?auth_plugin=mysql_native_password')except engine.closed(): print("Failed to create engine")
如何防止有人打印 cryptography.fernet 包中的解密密碼
慕的地8271018
2023-09-19 17:36:03