first commit
commit
046bbafa4e
|
|
@ -0,0 +1,2 @@
|
|||
./venv/
|
||||
.idea/
|
||||
|
|
@ -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()
|
||||
|
|
@ -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()
|
||||
|
|
@ -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}")
|
||||
Loading…
Reference in New Issue