遮盖 API Key,只显示前4位和后4位 Args: key: 原始 API Key Returns: str: 遮盖后的 API Key
(key: str)
| 98 | |
| 99 | |
| 100 | def mask_api_key(key: str) -> str: |
| 101 | """ |
| 102 | 遮盖 API Key,只显示前4位和后4位 |
| 103 | |
| 104 | Args: |
| 105 | key: 原始 API Key |
| 106 | |
| 107 | Returns: |
| 108 | str: 遮盖后的 API Key |
| 109 | """ |
| 110 | if not key: |
| 111 | return '' |
| 112 | if len(key) <= 8: |
| 113 | return '*' * len(key) |
| 114 | return key[:4] + '*' * (len(key) - 8) + key[-4:] |
| 115 | |
| 116 | |
| 117 | def prepare_providers_for_response(providers: dict) -> dict: |
no outgoing calls
no test coverage detected