From abb79f455202b8966c1e78f86012a22ee12e2176 Mon Sep 17 00:00:00 2001 From: limoruirui <1776862618@qq.com> Date: Sun, 13 Nov 2022 00:21:53 +0800 Subject: [PATCH] =?UTF-8?q?pycryptdemo=E5=8A=A0=E5=AF=86=E5=BA=93=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/aes_encrypt.py | 6 +++++- tools/encrypt_symmetric.py | 6 +++++- tools/rsa_encrypt.py | 8 ++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/tools/aes_encrypt.py b/tools/aes_encrypt.py index 5f943a9..7cc662e 100644 --- a/tools/aes_encrypt.py +++ b/tools/aes_encrypt.py @@ -9,7 +9,11 @@ aes加密解密工具 目前仅支持ECB/CBC 块长度均为128位 padding只支 pycryptdemo限制 同一个aes加密对象不能即加密又解密 所以当加密和解密都需要执行时 需要重新new一个对象增加额外开销 -- A cipher object is stateful: once you have encrypted a message , you cannot encrypt (or decrypt) another message using the same object.  """ -from Crypto.Cipher import AES +try: + from Crypto.Cipher import AES +except: + print("检测到还未安装 pycryptdemo 请按照md的方法安装") + exit(0) from binascii import b2a_hex, a2b_hex from base64 import b64encode, b64decode class AES_Ctypt: diff --git a/tools/encrypt_symmetric.py b/tools/encrypt_symmetric.py index 2160590..feea8e6 100644 --- a/tools/encrypt_symmetric.py +++ b/tools/encrypt_symmetric.py @@ -15,7 +15,11 @@ aes加密解密工具 目前仅支持ECB/CBC 块长度均为128位 padding只支 pycryptdemo限制 同一个aes加密对象不能即加密又解密 所以当加密和解密都需要执行时 需要重新new一个对象增加额外开销 -- A cipher object is stateful: once you have encrypted a message , you cannot encrypt (or decrypt) another message using the same object.  """ -from Crypto.Cipher import AES, DES, DES3 +try: + from Crypto.Cipher import AES, DES, DES3 +except: + print("检测到还未安装 pycryptdemo 请按照md的方法安装") + exit(0) from binascii import b2a_hex, a2b_hex from base64 import b64encode, b64decode diff --git a/tools/rsa_encrypt.py b/tools/rsa_encrypt.py index b215943..54ccc1f 100644 --- a/tools/rsa_encrypt.py +++ b/tools/rsa_encrypt.py @@ -4,8 +4,12 @@ # @Author : github@limoruirui https://github.com/limoruirui # @Time : 2022/8/23 13:05 # ------------------------------- -from Crypto.PublicKey.RSA import importKey, construct -from Crypto.Cipher import PKCS1_v1_5 +try: + from Crypto.PublicKey.RSA import importKey, construct + from Crypto.Cipher import PKCS1_v1_5 +except: + print("检测到还未安装 pycryptdemo 请按照md的方法安装") + exit(0) from base64 import b64encode