MCPcopy Create free account
hub / github.com/HisMax/RedInk / mask_api_key

Function mask_api_key

backend/routes/utils.py:100–114  ·  view source on GitHub ↗

遮盖 API Key,只显示前4位和后4位 Args: key: 原始 API Key Returns: str: 遮盖后的 API Key

(key: str)

Source from the content-addressed store, hash-verified

98
99
100def 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
117def prepare_providers_for_response(providers: dict) -> dict:

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected