#151 New Feature: API KEY Masking

新功能:API KEY 脱敏处理。前端和API接口中,用*号代替。
This commit is contained in:
Physton
2023-07-14 17:02:12 +08:00
parent 34b4889e56
commit 845e38cae8
10 changed files with 196 additions and 44 deletions

View File

@@ -53,6 +53,8 @@ class Storage:
filename = self.__get_data_filename(key)
if not os.path.exists(filename):
return None
if os.path.getsize(filename) == 0:
return None
try:
import launch
if not launch.is_installed("chardet"):
@@ -65,8 +67,12 @@ class Storage:
encoding = chardet.detect(data).get('encoding')
data = json.loads(data.decode(encoding))
except Exception as e:
print(e)
return None
try:
with open(filename, 'r') as f:
data = json.load(f)
except Exception as e:
print(e)
return None
return data
def __set(self, key, data):