xtn-tools-pro 1.0.0.7.1__tar.gz → 1.0.0.7.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. {xtn-tools-pro-1.0.0.7.1/xtn_tools_pro.egg-info → xtn-tools-pro-1.0.0.7.2}/PKG-INFO +1 -1
  2. {xtn-tools-pro-1.0.0.7.1 → xtn-tools-pro-1.0.0.7.2}/setup.py +3 -2
  3. {xtn-tools-pro-1.0.0.7.1 → xtn-tools-pro-1.0.0.7.2}/xtn_tools_pro/utils/crypto.py +31 -0
  4. {xtn-tools-pro-1.0.0.7.1 → xtn-tools-pro-1.0.0.7.2/xtn_tools_pro.egg-info}/PKG-INFO +1 -1
  5. {xtn-tools-pro-1.0.0.7.1 → xtn-tools-pro-1.0.0.7.2}/xtn_tools_pro.egg-info/requires.txt +1 -0
  6. {xtn-tools-pro-1.0.0.7.1 → xtn-tools-pro-1.0.0.7.2}/LICENSE +0 -0
  7. {xtn-tools-pro-1.0.0.7.1 → xtn-tools-pro-1.0.0.7.2}/README.md +0 -0
  8. {xtn-tools-pro-1.0.0.7.1 → xtn-tools-pro-1.0.0.7.2}/setup.cfg +0 -0
  9. {xtn-tools-pro-1.0.0.7.1 → xtn-tools-pro-1.0.0.7.2}/xtn_tools_pro/__init__.py +0 -0
  10. {xtn-tools-pro-1.0.0.7.1 → xtn-tools-pro-1.0.0.7.2}/xtn_tools_pro/db/MongoDB.py +0 -0
  11. {xtn-tools-pro-1.0.0.7.1 → xtn-tools-pro-1.0.0.7.2}/xtn_tools_pro/db/MysqlDB.py +0 -0
  12. {xtn-tools-pro-1.0.0.7.1 → xtn-tools-pro-1.0.0.7.2}/xtn_tools_pro/db/RedisDB.py +0 -0
  13. {xtn-tools-pro-1.0.0.7.1 → xtn-tools-pro-1.0.0.7.2}/xtn_tools_pro/db/__init__.py +0 -0
  14. {xtn-tools-pro-1.0.0.7.1 → xtn-tools-pro-1.0.0.7.2}/xtn_tools_pro/proxy/XiaoXiangProxy.py +0 -0
  15. {xtn-tools-pro-1.0.0.7.1 → xtn-tools-pro-1.0.0.7.2}/xtn_tools_pro/proxy/__init__.py +0 -0
  16. {xtn-tools-pro-1.0.0.7.1 → xtn-tools-pro-1.0.0.7.2}/xtn_tools_pro/proxy/proxy.py +0 -0
  17. {xtn-tools-pro-1.0.0.7.1 → xtn-tools-pro-1.0.0.7.2}/xtn_tools_pro/task_pro/__init__.py +0 -0
  18. {xtn-tools-pro-1.0.0.7.1 → xtn-tools-pro-1.0.0.7.2}/xtn_tools_pro/task_pro/go_fun.py +0 -0
  19. {xtn-tools-pro-1.0.0.7.1 → xtn-tools-pro-1.0.0.7.2}/xtn_tools_pro/task_pro/go_fun_v2.py +0 -0
  20. {xtn-tools-pro-1.0.0.7.1 → xtn-tools-pro-1.0.0.7.2}/xtn_tools_pro/task_pro/go_fun_v3.py +0 -0
  21. {xtn-tools-pro-1.0.0.7.1 → xtn-tools-pro-1.0.0.7.2}/xtn_tools_pro/tools.py +0 -0
  22. {xtn-tools-pro-1.0.0.7.1 → xtn-tools-pro-1.0.0.7.2}/xtn_tools_pro/utils/__init__.py +0 -0
  23. {xtn-tools-pro-1.0.0.7.1 → xtn-tools-pro-1.0.0.7.2}/xtn_tools_pro/utils/file_utils.py +0 -0
  24. {xtn-tools-pro-1.0.0.7.1 → xtn-tools-pro-1.0.0.7.2}/xtn_tools_pro/utils/helpers.py +0 -0
  25. {xtn-tools-pro-1.0.0.7.1 → xtn-tools-pro-1.0.0.7.2}/xtn_tools_pro/utils/log.py +0 -0
  26. {xtn-tools-pro-1.0.0.7.1 → xtn-tools-pro-1.0.0.7.2}/xtn_tools_pro/utils/retry.py +0 -0
  27. {xtn-tools-pro-1.0.0.7.1 → xtn-tools-pro-1.0.0.7.2}/xtn_tools_pro/utils/sql.py +0 -0
  28. {xtn-tools-pro-1.0.0.7.1 → xtn-tools-pro-1.0.0.7.2}/xtn_tools_pro/utils/time_utils.py +0 -0
  29. {xtn-tools-pro-1.0.0.7.1 → xtn-tools-pro-1.0.0.7.2}/xtn_tools_pro.egg-info/SOURCES.txt +0 -0
  30. {xtn-tools-pro-1.0.0.7.1 → xtn-tools-pro-1.0.0.7.2}/xtn_tools_pro.egg-info/dependency_links.txt +0 -0
  31. {xtn-tools-pro-1.0.0.7.1 → xtn-tools-pro-1.0.0.7.2}/xtn_tools_pro.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xtn-tools-pro
3
- Version: 1.0.0.7.1
3
+ Version: 1.0.0.7.2
4
4
  Summary: xtn 开发工具
5
5
  Author: xtn
6
6
  Author-email: czw011122@gmail.com
@@ -15,7 +15,7 @@ with open("README.md", "r") as f:
15
15
 
16
16
  setuptools.setup(
17
17
  name="xtn-tools-pro", # 模块名称
18
- version="1.0.0.7.1", # 版本
18
+ version="1.0.0.7.2", # 版本
19
19
  author="xtn", # 作者
20
20
  author_email="czw011122@gmail.com", # 作者邮箱
21
21
  description="xtn 开发工具", # 模块简介
@@ -34,7 +34,8 @@ setuptools.setup(
34
34
  "dbutils",
35
35
  "colorlog",
36
36
  "requests",
37
- "Faker"
37
+ "Faker",
38
+ "PyJWT"
38
39
  ],
39
40
  python_requires='>=3',
40
41
  )
@@ -8,8 +8,11 @@
8
8
  # --------------------------------------------------------------------------------------------------
9
9
  # 2024/5/13 xiatn V00.01.000 新建
10
10
  # --------------------------------------------------------------------------------------------------
11
+ import jwt
11
12
  import base64
12
13
  import hashlib
14
+ import secrets
15
+ import datetime
13
16
 
14
17
 
15
18
  def get_md5_32(s: str, is_upper=False):
@@ -117,5 +120,33 @@ def get_base64_encode(s: str):
117
120
  return encoded_string
118
121
 
119
122
 
123
+ def generate_bearer_token(secret_key, expiration=0, algorithm='HS256', **kwargs):
124
+ """
125
+ 生成 Bearer Token
126
+ :param secret_key: 用于加密的密钥
127
+ :param expiration: 过期时间戳,0则表示不过期
128
+ :param algorithm: 使用的加密算法(默认是 HS256)HS256、HS384、HS512
129
+ :param kwargs: 其他自定义的 Token 数据
130
+ :return: 生成的 Bearer Token
131
+ """
132
+ payload = {
133
+ **kwargs # 将其他参数添加到 payload
134
+ }
135
+ if expiration:
136
+ payload['exp'] = expiration
137
+
138
+ token = jwt.encode(payload, secret_key, algorithm=algorithm)
139
+ return token
140
+
141
+
142
+ def generate_secret_key(length=32):
143
+ """
144
+ 生成一个随机的 secret key
145
+ :param length: key 的长度,默认为 32
146
+ :return: 生成的 secret key
147
+ """
148
+ return secrets.token_hex(length)
149
+
150
+
120
151
  if __name__ == '__main__':
121
152
  print(get_base64_encode(''))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xtn-tools-pro
3
- Version: 1.0.0.7.1
3
+ Version: 1.0.0.7.2
4
4
  Summary: xtn 开发工具
5
5
  Author: xtn
6
6
  Author-email: czw011122@gmail.com
@@ -5,3 +5,4 @@ dbutils
5
5
  colorlog
6
6
  requests
7
7
  Faker
8
+ PyJWT