From 046bbafa4e949306c3a8bfef8b717b9095252267 Mon Sep 17 00:00:00 2001 From: wangsiyuan <2392948297@qq.com> Date: Thu, 28 Nov 2024 19:38:45 +0800 Subject: [PATCH] first commit --- .gitignore | 2 ++ testConnectMinio.py | 32 ++++++++++++++++++++++++++++++++ testConnectMySQL.py | 41 +++++++++++++++++++++++++++++++++++++++++ testlvl.py | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 110 insertions(+) create mode 100644 .gitignore create mode 100644 testConnectMinio.py create mode 100644 testConnectMySQL.py create mode 100644 testlvl.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9610f72 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +./venv/ +.idea/ \ No newline at end of file diff --git a/testConnectMinio.py b/testConnectMinio.py new file mode 100644 index 0000000..aed3cc5 --- /dev/null +++ b/testConnectMinio.py @@ -0,0 +1,32 @@ +from minio import Minio +from minio.error import S3Error + +def test_minio_connection(): + # MinIO 配置 + config = { + "endpoint": "192.168.2.20:9002", + "access_key": "zw4bi7qgyupVbouWonlr", + "secret_key": "ETelFUk0mDf5ITpwJAeIqgLi8UQ1S953001eq6sq", + "secure": False # 是否使用 HTTPS + } + + try: + # 创建 MinIO 客户端 + client = Minio( + config["endpoint"], + access_key=config["access_key"], + secret_key=config["secret_key"], + secure=config["secure"] + ) + + # 测试列出所有存储桶 + buckets = client.list_buckets() + print("成功连接到 MinIO!以下是现有的存储桶列表:") + for bucket in buckets: + print(f" - {bucket.name}") + + except S3Error as e: + print(f"连接 MinIO 时发生错误: {e}") + +if __name__ == "__main__": + test_minio_connection() \ No newline at end of file diff --git a/testConnectMySQL.py b/testConnectMySQL.py new file mode 100644 index 0000000..6e67223 --- /dev/null +++ b/testConnectMySQL.py @@ -0,0 +1,41 @@ +import mysql.connector +from mysql.connector import Error + +def test_mysql_connection(): + # MySQL 配置 + config = { + 'host': '192.168.2.20', + 'port': 8006, + 'user': 'mticloud', + 'password': 'fT3KsNDahADGcWCZ', + 'database': 'mti-cloud', + 'charset': 'utf8mb4' + } + + try: + # 建立连接 + connection = mysql.connector.connect(**config) + + if connection.is_connected(): + print("成功连接到 MySQL 数据库!") + # 打印数据库信息 + db_info = connection.get_server_info() + print(f"MySQL 服务器版本: {db_info}") + cursor = connection.cursor() + cursor.execute("SELECT DATABASE();") + record = cursor.fetchone() + print(f"当前使用的数据库: {record[0]}") + + except Error as e: + print(f"连接 MySQL 时发生错误: {e}") + + finally: + # 关闭连接 + if connection.is_connected(): + cursor.close() + connection.close() + print("MySQL 连接已关闭。") + +# 执行测试 +if __name__ == "__main__": + test_mysql_connection() \ No newline at end of file diff --git a/testlvl.py b/testlvl.py new file mode 100644 index 0000000..33745b1 --- /dev/null +++ b/testlvl.py @@ -0,0 +1,35 @@ +import base64 +import rsa + +# Google Play Developer Console 生成的 Base64 编码的 RSA 公钥 +BASE64_PUBLIC_KEY = "YOUR_PUBLIC_KEY" + + +def verify_signature(signature, signature_data, timestamp): + try: + # 解码公钥 + public_key_bytes = base64.b64decode(BASE64_PUBLIC_KEY) + public_key = rsa.PublicKey.load_pkcs1_openssl_pem(public_key_bytes) + + # 将签名数据和时间戳组合 + message = f"{signature_data}:{timestamp}".encode('utf-8') + + # 解码签名 + signature_bytes = base64.b64decode(signature) + + # 验证签名 + rsa.verify(message, signature_bytes, public_key) + + return True + except Exception as e: + print(f"验证签名失败: {e}") + return False + + +# 示例数据 +signature = "jV1Iy1CvfAqLqw1XWocBQVgY4RsGbh1e0CZm8FOnynFSx2tLR9OCzIzJOyRo4T198lcYCgOdqiKvqvpkvYyp6gUGPY9SlHa0qRXyTM0umOwA8c+JkgfuSPD3x51J0yBwDLNmeLImCwj5je5TSe3wIP4c3Fs6PkJQgo4zFRUHMBfThunAF4niithzf1QjYn3FWYbJptFE+HUWkjVfbtRy9vGGUFGW3oqv+djyhEgpxH4R/ZRmYrzGyy7EDqfjh7TLLcofKInZNCbTs27/Vj/35xhdGx1DUaeV6oFngNNjTIKpw44LboEwN4B5ac4hx1nfXuYKEcic/gw2lxEgj1t/RQ==" +signature_data = "your_signature_data" +timestamp = "your_timestamp" + +is_valid = verify_signature(signature, signature_data, timestamp) +print(f"签名验证结果: {is_valid}")