#!/usr/bin/env python3 """ 检查JWT密钥长度 """ import base64 # Gateway配置的secret gateway_secret = "U2FsdGVkX1+vZ5Y9QmKxL8nN3rP7tW2jH4fG6dA8sB1cE5yN0zX3qV7wM4" # Manage-app默认的secret default_secret = "default-secret-key-change-in-production" print("Gateway secret:") print(f" 长度: {len(gateway_secret)} bytes") print(f" Base64解码后长度: {len(base64.b64decode(gateway_secret + '=='))} bytes") print(f"\nManage-app默认secret:") print(f" 长度: {len(default_secret)} bytes") print("\nJWT算法要求:") print(" HS256: 至少32 bytes (256 bits)") print(" HS384: 至少48 bytes (384 bits)") print(" HS512: 至少64 bytes (512 bits)") print(f"\nGateway secret长度 {len(gateway_secret)} bytes:") if len(gateway_secret) >= 64: print(" 支持 HS512") elif len(gateway_secret) >= 48: print(" 支持 HS384") elif len(gateway_secret) >= 32: print(" 支持 HS256") else: print(" 不满足任何算法要求") print(f"\nManage-app默认secret长度 {len(default_secret)} bytes:") if len(default_secret) >= 64: print(" 支持 HS512") elif len(default_secret) >= 48: print(" 支持 HS384") elif len(default_secret) >= 32: print(" 支持 HS256") else: print(" 不满足任何算法要求")