antkit 0.0.2__tar.gz → 0.0.4__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.
antkit-0.0.4/PKG-INFO ADDED
@@ -0,0 +1,88 @@
1
+ Metadata-Version: 2.5
2
+ Name: antkit
3
+ Version: 0.0.4
4
+ Summary: 密码学安全的随机 token 与口令生成。
5
+ Project-URL: Homepage, https://pypi.org/project/antkit/
6
+ Author-email: lqxnjk <lqxnjk@qq.com>
7
+ License: MIT
8
+ License-File: LICENSE
9
+ Keywords: password,random,secrets,security,token
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
+ Classifier: Typing :: Typed
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+
21
+ # antkit
22
+
23
+ [English](#english) | 中文
24
+
25
+ 密码学安全的随机 token 与口令生成。
26
+
27
+ ## 安装
28
+
29
+ ```console
30
+ pip install antkit
31
+ ```
32
+
33
+ ## 用法
34
+
35
+ ```python
36
+ from antkit import password, token
37
+
38
+ token() # 22 字符,16 字节熵
39
+ token(n_bytes=32)
40
+ token(n_urlsafe=False) # hex
41
+
42
+ password() # 16 位,四类字符全用
43
+ password(24, n_symbols=False)
44
+ password(12, n_lower=False, n_upper=False)
45
+ ```
46
+
47
+ ## 说明
48
+
49
+ 全部基于 `secrets`,不用 `random`(它的种子可预测,不能用于任何不该被猜到的值)。口令保证每个启用的字符类至少出现一次,然后整体打乱,避免保底字符堆在开头。请求不可能满足时抛 `ValueError`。
50
+
51
+ ## 许可证
52
+
53
+ MIT
54
+
55
+ ---
56
+
57
+ <a id="english"></a>
58
+ ## English
59
+
60
+ Cryptographically secure tokens and passwords.
61
+
62
+ ## Install
63
+
64
+ ```console
65
+ pip install antkit
66
+ ```
67
+
68
+ ## Usage
69
+
70
+ ```python
71
+ from antkit import password, token
72
+
73
+ token() # 22 字符,16 字节熵
74
+ token(n_bytes=32)
75
+ token(n_urlsafe=False) # hex
76
+
77
+ password() # 16 位,四类字符全用
78
+ password(24, n_symbols=False)
79
+ password(12, n_lower=False, n_upper=False)
80
+ ```
81
+
82
+ ## Notes
83
+
84
+ Built on `secrets`, never `random`. Passwords always contain at least one character from every enabled class, then get shuffled so the guaranteed characters are not stuck at the front. Impossible requests raise `ValueError`.
85
+
86
+ ## License
87
+
88
+ MIT
antkit-0.0.4/README.md ADDED
@@ -0,0 +1,68 @@
1
+ # antkit
2
+
3
+ [English](#english) | 中文
4
+
5
+ 密码学安全的随机 token 与口令生成。
6
+
7
+ ## 安装
8
+
9
+ ```console
10
+ pip install antkit
11
+ ```
12
+
13
+ ## 用法
14
+
15
+ ```python
16
+ from antkit import password, token
17
+
18
+ token() # 22 字符,16 字节熵
19
+ token(n_bytes=32)
20
+ token(n_urlsafe=False) # hex
21
+
22
+ password() # 16 位,四类字符全用
23
+ password(24, n_symbols=False)
24
+ password(12, n_lower=False, n_upper=False)
25
+ ```
26
+
27
+ ## 说明
28
+
29
+ 全部基于 `secrets`,不用 `random`(它的种子可预测,不能用于任何不该被猜到的值)。口令保证每个启用的字符类至少出现一次,然后整体打乱,避免保底字符堆在开头。请求不可能满足时抛 `ValueError`。
30
+
31
+ ## 许可证
32
+
33
+ MIT
34
+
35
+ ---
36
+
37
+ <a id="english"></a>
38
+ ## English
39
+
40
+ Cryptographically secure tokens and passwords.
41
+
42
+ ## Install
43
+
44
+ ```console
45
+ pip install antkit
46
+ ```
47
+
48
+ ## Usage
49
+
50
+ ```python
51
+ from antkit import password, token
52
+
53
+ token() # 22 字符,16 字节熵
54
+ token(n_bytes=32)
55
+ token(n_urlsafe=False) # hex
56
+
57
+ password() # 16 位,四类字符全用
58
+ password(24, n_symbols=False)
59
+ password(12, n_lower=False, n_upper=False)
60
+ ```
61
+
62
+ ## Notes
63
+
64
+ Built on `secrets`, never `random`. Passwords always contain at least one character from every enabled class, then get shuffled so the guaranteed characters are not stuck at the front. Impossible requests raise `ValueError`.
65
+
66
+ ## License
67
+
68
+ MIT
@@ -4,12 +4,12 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "antkit"
7
- version = "0.0.2"
8
- description = "Cryptographically secure tokens and passwords."
7
+ version = "0.0.4"
8
+ description = "密码学安全的随机 token 与口令生成。"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
11
11
  license = { text = "MIT" }
12
- authors = [{ name = "lqxnjk" }]
12
+ authors = [{ name = "lqxnjk", email = "lqxnjk@qq.com" }]
13
13
  keywords = ["token", "password", "secrets", "random", "security"]
14
14
  classifiers = [
15
15
  "Development Status :: 3 - Alpha",
@@ -24,7 +24,7 @@ classifiers = [
24
24
  dependencies = []
25
25
 
26
26
  [project.urls]
27
- Homepage = "https://github.com/lqxnjk/antkit"
27
+ Homepage = "https://pypi.org/project/antkit/"
28
28
 
29
29
  [tool.pytest.ini_options]
30
30
  pythonpath = ["src"]
@@ -1,11 +1,10 @@
1
1
  """
2
2
  Author: lqxnjk <lqxnjk@qq.com>
3
- Created: 2026-10-23 10:25
4
- Modified: 2026-10-23 10:25
3
+ Created: 2026-10-23 10:55
4
+ Modified: 2026-10-23 11:49
5
5
  Python Version: 3.10
6
6
  Secure random tokens and passwords.
7
7
  """
8
-
9
8
  from __future__ import annotations
10
9
 
11
10
  import secrets
@@ -19,21 +18,21 @@ _DIGITS = string.digits
19
18
  _SYMBOLS = "!@#$%^&*()-_=+[]{};:,.?"
20
19
 
21
20
 
22
- def token(m_bytes: int = 16, n_urlsafe: bool = True) -> str:
23
- """Return a URL-safe token carrying ``m_bytes`` of entropy.
21
+ def token(n_bytes: int = 16, n_urlsafe: bool = True) -> str:
22
+ """Return a URL-safe token carrying ``n_bytes`` of entropy.
24
23
 
25
24
  Built on :mod:`secrets`, so it is suitable for session IDs, API keys and
26
- reset links. Length is longer than ``m_bytes`` because base64 expands.
25
+ reset links. Length is longer than ``n_bytes`` because base64 expands.
27
26
  """
28
- if m_bytes < 1:
29
- raise ValueError(f"m_bytes must be >= 1, got {m_bytes}")
27
+ if n_bytes < 1:
28
+ raise ValueError(f"n_bytes must be >= 1, got {n_bytes}")
30
29
  if n_urlsafe:
31
- return secrets.token_urlsafe(m_bytes)
32
- return secrets.token_hex(m_bytes)
30
+ return secrets.token_urlsafe(n_bytes)
31
+ return secrets.token_hex(n_bytes)
33
32
 
34
33
 
35
34
  def password(
36
- m_length: int = 16,
35
+ n_length: int = 16,
37
36
  n_lower: bool = True,
38
37
  n_upper: bool = True,
39
38
  n_digits: bool = True,
@@ -56,12 +55,12 @@ def password(
56
55
  pools.append(_SYMBOLS)
57
56
  if not pools:
58
57
  raise ValueError("at least one character class must be enabled")
59
- if m_length < len(pools):
60
- raise ValueError(f"m_length must be >= {len(pools)} for {len(pools)} class(es)")
58
+ if n_length < len(pools):
59
+ raise ValueError(f"n_length must be >= {len(pools)} for {len(pools)} class(es)")
61
60
 
62
61
  alphabet = "".join(pools)
63
62
  chars = [secrets.choice(pool) for pool in pools]
64
- chars.extend(secrets.choice(alphabet) for _ in range(m_length - len(chars)))
63
+ chars.extend(secrets.choice(alphabet) for _ in range(n_length - len(chars)))
65
64
  for index in range(len(chars) - 1, 0, -1):
66
65
  swap = secrets.randbelow(index + 1)
67
66
  chars[index], chars[swap] = chars[swap], chars[index]
@@ -1,10 +1,9 @@
1
1
  """
2
2
  Author: lqxnjk <lqxnjk@qq.com>
3
- Created: 2026-10-23 10:25
4
- Modified: 2026-10-23 10:25
3
+ Created: 2026-10-23 10:55
4
+ Modified: 2026-10-23 11:49
5
5
  Python Version: 3.10
6
6
  """
7
-
8
7
  import string
9
8
 
10
9
  import pytest
antkit-0.0.2/PKG-INFO DELETED
@@ -1,59 +0,0 @@
1
- Metadata-Version: 2.5
2
- Name: antkit
3
- Version: 0.0.2
4
- Summary: Cryptographically secure tokens and passwords.
5
- Project-URL: Homepage, https://github.com/lqxnjk/antkit
6
- Author: lqxnjk
7
- License: MIT
8
- License-File: LICENSE
9
- Keywords: password,random,secrets,security,token
10
- Classifier: Development Status :: 3 - Alpha
11
- Classifier: Intended Audience :: Developers
12
- Classifier: License :: OSI Approved :: MIT License
13
- Classifier: Operating System :: OS Independent
14
- Classifier: Programming Language :: Python :: 3
15
- Classifier: Programming Language :: Python :: 3 :: Only
16
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
- Classifier: Typing :: Typed
18
- Requires-Python: >=3.10
19
- Description-Content-Type: text/markdown
20
-
21
- # antkit
22
-
23
- Generate tokens and passwords with `secrets` — never with `random`.
24
-
25
- ## Install
26
-
27
- ```console
28
- pip install antkit
29
- ```
30
-
31
- ## Usage
32
-
33
- ```python
34
- from antkit import password, token
35
-
36
- token() # 22-char URL-safe string, 16 bytes of entropy
37
- token(m_bytes=32) # longer
38
- token(n_urlsafe=False) # hex instead
39
-
40
- password() # 16 chars, all four classes
41
- password(24, n_symbols=False)
42
- password(12, n_lower=False, n_upper=False) # digits + symbols only
43
- ```
44
-
45
- ## Guarantees
46
-
47
- | Function | Guarantee |
48
- | --- | --- |
49
- | `token` | `secrets`-backed, URL-safe by default |
50
- | `password` | at least one character from every enabled class |
51
- | `password` | order shuffled, guaranteed chars are not prefix-stuck |
52
- | both | `ValueError` on impossible requests |
53
-
54
- `random` is not used anywhere: it is seeded predictably and is the wrong tool
55
- for anything a user must not guess.
56
-
57
- ## License
58
-
59
- MIT
antkit-0.0.2/README.md DELETED
@@ -1,39 +0,0 @@
1
- # antkit
2
-
3
- Generate tokens and passwords with `secrets` — never with `random`.
4
-
5
- ## Install
6
-
7
- ```console
8
- pip install antkit
9
- ```
10
-
11
- ## Usage
12
-
13
- ```python
14
- from antkit import password, token
15
-
16
- token() # 22-char URL-safe string, 16 bytes of entropy
17
- token(m_bytes=32) # longer
18
- token(n_urlsafe=False) # hex instead
19
-
20
- password() # 16 chars, all four classes
21
- password(24, n_symbols=False)
22
- password(12, n_lower=False, n_upper=False) # digits + symbols only
23
- ```
24
-
25
- ## Guarantees
26
-
27
- | Function | Guarantee |
28
- | --- | --- |
29
- | `token` | `secrets`-backed, URL-safe by default |
30
- | `password` | at least one character from every enabled class |
31
- | `password` | order shuffled, guaranteed chars are not prefix-stuck |
32
- | both | `ValueError` on impossible requests |
33
-
34
- `random` is not used anywhere: it is seeded predictably and is the wrong tool
35
- for anything a user must not guess.
36
-
37
- ## License
38
-
39
- MIT
File without changes
File without changes