silasyn-uid 1.0.0__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.
- silasyn_uid-1.0.0/LICENSE.md +42 -0
- silasyn_uid-1.0.0/PKG-INFO +253 -0
- silasyn_uid-1.0.0/README.md +240 -0
- silasyn_uid-1.0.0/pyproject.toml +21 -0
- silasyn_uid-1.0.0/setup.cfg +4 -0
- silasyn_uid-1.0.0/silasyn_uid.egg-info/PKG-INFO +253 -0
- silasyn_uid-1.0.0/silasyn_uid.egg-info/SOURCES.txt +8 -0
- silasyn_uid-1.0.0/silasyn_uid.egg-info/dependency_links.txt +1 -0
- silasyn_uid-1.0.0/silasyn_uid.egg-info/top_level.txt +1 -0
- silasyn_uid-1.0.0/silasyn_uid.py +194 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2026 Silasyn
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
|
|
13
|
+
in the Software without restriction, including without limitation the rights
|
|
14
|
+
|
|
15
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
|
|
17
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
|
|
19
|
+
furnished to do so, subject to the following conditions:
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
The above copyright notice and this permission notice shall be included in all
|
|
24
|
+
|
|
25
|
+
copies or substantial portions of the Software.
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
30
|
+
|
|
31
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
32
|
+
|
|
33
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
34
|
+
|
|
35
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
36
|
+
|
|
37
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
38
|
+
|
|
39
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
40
|
+
|
|
41
|
+
SOFTWARE.
|
|
42
|
+
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: silasyn-uid
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Official zero-dependency Python client for Silasyn UID Studio Pro with automatic offline fallback.
|
|
5
|
+
Author-email: Silasyn <support@silasyn.com>
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Requires-Python: >=3.7
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE.md
|
|
12
|
+
Dynamic: license-file
|
|
13
|
+
|
|
14
|
+
Silasyn UID Studio Pro - Python Client
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
Official, zero-dependency Python client for generating secure, customizable unique identifiers using the Silasyn UID Studio Pro API.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
Features
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
Zero Dependencies: Built entirely on Python's native standard libraries (urllib, json, uuid, secrets, time). No need to install requests.
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
Automatic Offline Fallback: If the API endpoint at silasyn.com is unreachable (due to network, firewall, or DNS issues), the client automatically switches to a high-precision local generation engine to guarantee 100% uptime.
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
Highly Customizable: Supports UUIDv4, UUIDv7 (Time-ordered), NanoID, Hexadecimal, Pure Numeric, and Custom pools with prefixes, suffixes, custom casings, and formatting.
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
Installation
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
Install the package from PyPI:
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
pip install silasyn-uid
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
Quick Start
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
from silasyn\_uid import UIDStudio
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
\# 1. Generate standard UUIDv4
|
|
61
|
+
|
|
62
|
+
uuids = UIDStudio.uuid4(count=2)
|
|
63
|
+
|
|
64
|
+
print(uuids)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
\# 2. Generate Time-ordered UUIDv7
|
|
69
|
+
|
|
70
|
+
uuid7s = UIDStudio.uuid7(count=1)
|
|
71
|
+
|
|
72
|
+
print(uuid7s)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
\# 3. Generate NanoIDs with a prefix
|
|
77
|
+
|
|
78
|
+
nanoids = UIDStudio.nanoid(count=3, length=12, prefix="user\_")
|
|
79
|
+
|
|
80
|
+
print(nanoids)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
\# 4. Generate custom hexadecimal keys
|
|
85
|
+
|
|
86
|
+
custom\_keys = UIDStudio.custom(pool="ABCDEF1234567890", count=2, length=16, hyphens=True)
|
|
87
|
+
|
|
88
|
+
print(custom\_keys)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
Configuration Parameters
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
The core generate method accepts the following arguments:
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
Parameter
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
Type
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
Default
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
Description
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
format\_type
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
str
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
"uuid4"
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
Options: "uuid4", "uuid7", "nanoid", "hex", "numeric", "custom"
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
count
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
int
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
1
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
Number of identifiers to generate (Max: 5000)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
length
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
int
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
21
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
Overall length of generated string (ignored for UUIDs)
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
prefix
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
str
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
""
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
Optional string to prepend
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
suffix
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
str
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
""
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
Optional string to append
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
hyphens
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
bool
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
True
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
Group characters into blocks separated by hyphens
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
casing
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
str
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
"mixed"
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
Set character case: "mixed", "lower", "upper"
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
custom\_pool
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
str
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
""
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
Alphanumeric pool used only when format\_type="custom"
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
License
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
Copyright © 2026 Silasyn. All rights reserved.
|
|
251
|
+
|
|
252
|
+
Distributed under the MIT License. See LICENSE for details.
|
|
253
|
+
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
Silasyn UID Studio Pro - Python Client
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
Official, zero-dependency Python client for generating secure, customizable unique identifiers using the Silasyn UID Studio Pro API.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Features
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
Zero Dependencies: Built entirely on Python's native standard libraries (urllib, json, uuid, secrets, time). No need to install requests.
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
Automatic Offline Fallback: If the API endpoint at silasyn.com is unreachable (due to network, firewall, or DNS issues), the client automatically switches to a high-precision local generation engine to guarantee 100% uptime.
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
Highly Customizable: Supports UUIDv4, UUIDv7 (Time-ordered), NanoID, Hexadecimal, Pure Numeric, and Custom pools with prefixes, suffixes, custom casings, and formatting.
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
Installation
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
Install the package from PyPI:
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
pip install silasyn-uid
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
Quick Start
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
from silasyn\_uid import UIDStudio
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
\# 1. Generate standard UUIDv4
|
|
48
|
+
|
|
49
|
+
uuids = UIDStudio.uuid4(count=2)
|
|
50
|
+
|
|
51
|
+
print(uuids)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
\# 2. Generate Time-ordered UUIDv7
|
|
56
|
+
|
|
57
|
+
uuid7s = UIDStudio.uuid7(count=1)
|
|
58
|
+
|
|
59
|
+
print(uuid7s)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
\# 3. Generate NanoIDs with a prefix
|
|
64
|
+
|
|
65
|
+
nanoids = UIDStudio.nanoid(count=3, length=12, prefix="user\_")
|
|
66
|
+
|
|
67
|
+
print(nanoids)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
\# 4. Generate custom hexadecimal keys
|
|
72
|
+
|
|
73
|
+
custom\_keys = UIDStudio.custom(pool="ABCDEF1234567890", count=2, length=16, hyphens=True)
|
|
74
|
+
|
|
75
|
+
print(custom\_keys)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
Configuration Parameters
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
The core generate method accepts the following arguments:
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
Parameter
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
Type
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
Default
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
Description
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
format\_type
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
str
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
"uuid4"
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
Options: "uuid4", "uuid7", "nanoid", "hex", "numeric", "custom"
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
count
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
int
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
1
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
Number of identifiers to generate (Max: 5000)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
length
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
int
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
21
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
Overall length of generated string (ignored for UUIDs)
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
prefix
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
str
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
""
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
Optional string to prepend
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
suffix
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
str
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
""
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
Optional string to append
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
hyphens
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
bool
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
True
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
Group characters into blocks separated by hyphens
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
casing
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
str
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
"mixed"
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
Set character case: "mixed", "lower", "upper"
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
custom\_pool
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
str
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
""
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
Alphanumeric pool used only when format\_type="custom"
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
License
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
Copyright © 2026 Silasyn. All rights reserved.
|
|
238
|
+
|
|
239
|
+
Distributed under the MIT License. See LICENSE for details.
|
|
240
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "silasyn-uid"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
authors = [
|
|
9
|
+
{ name = "Silasyn", email = "support@silasyn.com" }
|
|
10
|
+
]
|
|
11
|
+
description = "Official zero-dependency Python client for Silasyn UID Studio Pro with automatic offline fallback."
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
requires-python = ">=3.7"
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Operating System :: OS Independent",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[tool.setuptools]
|
|
21
|
+
py-modules = ["silasyn_uid"]
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: silasyn-uid
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Official zero-dependency Python client for Silasyn UID Studio Pro with automatic offline fallback.
|
|
5
|
+
Author-email: Silasyn <support@silasyn.com>
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Requires-Python: >=3.7
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE.md
|
|
12
|
+
Dynamic: license-file
|
|
13
|
+
|
|
14
|
+
Silasyn UID Studio Pro - Python Client
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
Official, zero-dependency Python client for generating secure, customizable unique identifiers using the Silasyn UID Studio Pro API.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
Features
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
Zero Dependencies: Built entirely on Python's native standard libraries (urllib, json, uuid, secrets, time). No need to install requests.
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
Automatic Offline Fallback: If the API endpoint at silasyn.com is unreachable (due to network, firewall, or DNS issues), the client automatically switches to a high-precision local generation engine to guarantee 100% uptime.
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
Highly Customizable: Supports UUIDv4, UUIDv7 (Time-ordered), NanoID, Hexadecimal, Pure Numeric, and Custom pools with prefixes, suffixes, custom casings, and formatting.
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
Installation
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
Install the package from PyPI:
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
pip install silasyn-uid
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
Quick Start
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
from silasyn\_uid import UIDStudio
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
\# 1. Generate standard UUIDv4
|
|
61
|
+
|
|
62
|
+
uuids = UIDStudio.uuid4(count=2)
|
|
63
|
+
|
|
64
|
+
print(uuids)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
\# 2. Generate Time-ordered UUIDv7
|
|
69
|
+
|
|
70
|
+
uuid7s = UIDStudio.uuid7(count=1)
|
|
71
|
+
|
|
72
|
+
print(uuid7s)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
\# 3. Generate NanoIDs with a prefix
|
|
77
|
+
|
|
78
|
+
nanoids = UIDStudio.nanoid(count=3, length=12, prefix="user\_")
|
|
79
|
+
|
|
80
|
+
print(nanoids)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
\# 4. Generate custom hexadecimal keys
|
|
85
|
+
|
|
86
|
+
custom\_keys = UIDStudio.custom(pool="ABCDEF1234567890", count=2, length=16, hyphens=True)
|
|
87
|
+
|
|
88
|
+
print(custom\_keys)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
Configuration Parameters
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
The core generate method accepts the following arguments:
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
Parameter
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
Type
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
Default
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
Description
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
format\_type
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
str
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
"uuid4"
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
Options: "uuid4", "uuid7", "nanoid", "hex", "numeric", "custom"
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
count
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
int
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
1
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
Number of identifiers to generate (Max: 5000)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
length
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
int
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
21
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
Overall length of generated string (ignored for UUIDs)
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
prefix
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
str
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
""
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
Optional string to prepend
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
suffix
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
str
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
""
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
Optional string to append
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
hyphens
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
bool
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
True
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
Group characters into blocks separated by hyphens
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
casing
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
str
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
"mixed"
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
Set character case: "mixed", "lower", "upper"
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
custom\_pool
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
str
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
""
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
Alphanumeric pool used only when format\_type="custom"
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
License
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
Copyright © 2026 Silasyn. All rights reserved.
|
|
251
|
+
|
|
252
|
+
Distributed under the MIT License. See LICENSE for details.
|
|
253
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
silasyn_uid
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Silasyn UID Studio Pro - Official Python Client
|
|
3
|
+
Copyright (c) 2026 Silasyn. All rights reserved.
|
|
4
|
+
|
|
5
|
+
A lightweight, zero-dependency wrapper for the Silasyn UID generation API.
|
|
6
|
+
Includes a robust offline fallback generator to guarantee 100% uptime.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import urllib.request
|
|
10
|
+
import urllib.parse
|
|
11
|
+
import json
|
|
12
|
+
import uuid
|
|
13
|
+
import secrets
|
|
14
|
+
import time
|
|
15
|
+
from typing import List
|
|
16
|
+
|
|
17
|
+
class UIDStudio:
|
|
18
|
+
"""
|
|
19
|
+
Client for interacting with the Silasyn UID API.
|
|
20
|
+
Automatically falls back to secure local generation when offline.
|
|
21
|
+
"""
|
|
22
|
+
BASE_URL = "https://silasyn.com/uid/api.php"
|
|
23
|
+
|
|
24
|
+
@classmethod
|
|
25
|
+
def generate(
|
|
26
|
+
cls,
|
|
27
|
+
format_type: str = "uuid4",
|
|
28
|
+
count: int = 1,
|
|
29
|
+
length: int = 21,
|
|
30
|
+
prefix: str = "",
|
|
31
|
+
suffix: str = "",
|
|
32
|
+
hyphens: bool = True,
|
|
33
|
+
casing: str = "mixed",
|
|
34
|
+
custom_pool: str = ""
|
|
35
|
+
) -> List[str]:
|
|
36
|
+
"""
|
|
37
|
+
Core method to generate UIDs via the Silasyn API.
|
|
38
|
+
Falls back to local generation if network query fails.
|
|
39
|
+
"""
|
|
40
|
+
params = {
|
|
41
|
+
"format": format_type,
|
|
42
|
+
"count": count,
|
|
43
|
+
"length": length,
|
|
44
|
+
"prefix": prefix,
|
|
45
|
+
"suffix": suffix,
|
|
46
|
+
"hyphens": "true" if hyphens else "false",
|
|
47
|
+
"casing": casing,
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if custom_pool and format_type == "custom":
|
|
51
|
+
params["customPool"] = custom_pool
|
|
52
|
+
|
|
53
|
+
query_string = urllib.parse.urlencode(params)
|
|
54
|
+
url = f"{cls.BASE_URL}?{query_string}"
|
|
55
|
+
|
|
56
|
+
try:
|
|
57
|
+
req = urllib.request.Request(url, headers={'User-Agent': 'Silasyn-Python-Client/1.0'})
|
|
58
|
+
# Set a 3-second timeout so offline scripts don't hang indefinitely
|
|
59
|
+
with urllib.request.urlopen(req, timeout=3.0) as response:
|
|
60
|
+
if response.status != 200:
|
|
61
|
+
raise ConnectionError(f"HTTP Error {response.status}: {response.reason}")
|
|
62
|
+
|
|
63
|
+
response_text = response.read().decode('utf-8')
|
|
64
|
+
data = json.loads(response_text)
|
|
65
|
+
|
|
66
|
+
if data.get("success"):
|
|
67
|
+
return data.get("data", [])
|
|
68
|
+
else:
|
|
69
|
+
raise ValueError("API response status returned failed.")
|
|
70
|
+
|
|
71
|
+
except Exception as e:
|
|
72
|
+
# Seamlessly switch to offline generation if DNS or network fails
|
|
73
|
+
print(f"[Silasyn API Warning] Offline or Connection Failed ({e}). Using local fallback...")
|
|
74
|
+
return cls._generate_locally(
|
|
75
|
+
format_type, count, length, prefix, suffix, hyphens, casing, custom_pool
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
@classmethod
|
|
79
|
+
def _generate_locally(
|
|
80
|
+
cls,
|
|
81
|
+
format_type: str,
|
|
82
|
+
count: int,
|
|
83
|
+
length: int,
|
|
84
|
+
prefix: str,
|
|
85
|
+
suffix: str,
|
|
86
|
+
hyphens: bool,
|
|
87
|
+
casing: str,
|
|
88
|
+
custom_pool: str
|
|
89
|
+
) -> List[str]:
|
|
90
|
+
"""
|
|
91
|
+
Backup local generation engine to maintain identical client behavior offline.
|
|
92
|
+
"""
|
|
93
|
+
local_data = []
|
|
94
|
+
for _ in range(count):
|
|
95
|
+
core = ""
|
|
96
|
+
if format_type == "uuid4":
|
|
97
|
+
u = str(uuid.uuid4())
|
|
98
|
+
core = u if hyphens else u.replace("-", "")
|
|
99
|
+
|
|
100
|
+
elif format_type == "uuid7":
|
|
101
|
+
# Local high-precision UUIDv7 logic matching PHP layout
|
|
102
|
+
ms = int(time.time() * 1000)
|
|
103
|
+
time_hex = f"{ms:012x}"
|
|
104
|
+
r1 = secrets.token_hex(2)[:3]
|
|
105
|
+
r2 = secrets.token_hex(6)
|
|
106
|
+
r2_val = int(r2[:3], 16) | 0x800
|
|
107
|
+
r2_part1 = f"{r2_val:03x}"
|
|
108
|
+
r2_part2 = r2[3:]
|
|
109
|
+
u = f"{time_hex[:8]}-{time_hex[8:]}-7{r1}-{r2_part1}-{r2_part2}"
|
|
110
|
+
core = u if hyphens else u.replace("-", "")
|
|
111
|
+
|
|
112
|
+
else:
|
|
113
|
+
# Map formatting pools
|
|
114
|
+
if format_type == "numeric":
|
|
115
|
+
pool = "0123456789"
|
|
116
|
+
elif format_type == "hex":
|
|
117
|
+
pool = "0123456789abcdef"
|
|
118
|
+
elif format_type == "nanoid":
|
|
119
|
+
pool = "_-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
|
120
|
+
elif format_type == "custom":
|
|
121
|
+
pool = custom_pool if custom_pool else "ABCDEF0123456789"
|
|
122
|
+
else:
|
|
123
|
+
pool = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
|
124
|
+
|
|
125
|
+
if format_type not in ["numeric", "nanoid", "custom"]:
|
|
126
|
+
if casing == "lower":
|
|
127
|
+
pool = pool.lower()
|
|
128
|
+
elif casing == "upper":
|
|
129
|
+
pool = pool.upper()
|
|
130
|
+
|
|
131
|
+
# De-duplicate character pool preserving order
|
|
132
|
+
pool = "".join(sorted(set(pool), key=pool.index))
|
|
133
|
+
|
|
134
|
+
# Construct characters
|
|
135
|
+
chars = []
|
|
136
|
+
for i in range(length):
|
|
137
|
+
if hyphens and i > 0 and i % 4 == 0 and i != length and format_type != "nanoid":
|
|
138
|
+
chars.append("-")
|
|
139
|
+
chars.append(secrets.choice(pool))
|
|
140
|
+
core = "".join(chars)
|
|
141
|
+
|
|
142
|
+
if format_type == "custom":
|
|
143
|
+
if casing == "lower":
|
|
144
|
+
core = core.lower()
|
|
145
|
+
elif casing == "upper":
|
|
146
|
+
core = core.upper()
|
|
147
|
+
|
|
148
|
+
local_data.append(f"{prefix}{core}{suffix}")
|
|
149
|
+
return local_data
|
|
150
|
+
|
|
151
|
+
# --- Convenience Methods ---
|
|
152
|
+
|
|
153
|
+
@classmethod
|
|
154
|
+
def uuid4(cls, count: int = 1, hyphens: bool = True, prefix: str = "") -> List[str]:
|
|
155
|
+
return cls.generate(format_type="uuid4", count=count, hyphens=hyphens, prefix=prefix)
|
|
156
|
+
|
|
157
|
+
@classmethod
|
|
158
|
+
def uuid7(cls, count: int = 1, hyphens: bool = True, prefix: str = "") -> List[str]:
|
|
159
|
+
return cls.generate(format_type="uuid7", count=count, hyphens=hyphens, prefix=prefix)
|
|
160
|
+
|
|
161
|
+
@classmethod
|
|
162
|
+
def nanoid(cls, count: int = 1, length: int = 21, prefix: str = "") -> List[str]:
|
|
163
|
+
return cls.generate(format_type="nanoid", count=count, length=length, hyphens=False, prefix=prefix)
|
|
164
|
+
|
|
165
|
+
@classmethod
|
|
166
|
+
def hex(cls, count: int = 1, length: int = 16, hyphens: bool = True, prefix: str = "") -> List[str]:
|
|
167
|
+
return cls.generate(format_type="hex", count=count, length=length, hyphens=hyphens, prefix=prefix)
|
|
168
|
+
|
|
169
|
+
@classmethod
|
|
170
|
+
def custom(cls, pool: str, count: int = 1, length: int = 16, hyphens: bool = False, prefix: str = "") -> List[str]:
|
|
171
|
+
return cls.generate(format_type="custom", custom_pool=pool, count=count, length=length, hyphens=hyphens, prefix=prefix)
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
# ==========================================
|
|
175
|
+
# Example Usage (Runs only if executed directly)
|
|
176
|
+
# ==========================================
|
|
177
|
+
if __name__ == "__main__":
|
|
178
|
+
print("Testing Silasyn UID Studio Pro API...\n")
|
|
179
|
+
|
|
180
|
+
# 1. Generate a standard UUIDv4
|
|
181
|
+
uuids = UIDStudio.uuid4(count=2)
|
|
182
|
+
print(f"UUIDv4: {uuids}")
|
|
183
|
+
|
|
184
|
+
# 2. Generate Time-ordered UUIDv7
|
|
185
|
+
uuid7s = UIDStudio.uuid7(count=1)
|
|
186
|
+
print(f"UUIDv7: {uuid7s}")
|
|
187
|
+
|
|
188
|
+
# 3. Generate NanoIDs with a prefix
|
|
189
|
+
nanoids = UIDStudio.nanoid(count=3, length=12, prefix="user_")
|
|
190
|
+
print(f"NanoID: {nanoids}")
|
|
191
|
+
|
|
192
|
+
# 4. Generate custom hexadecimal keys
|
|
193
|
+
custom_keys = UIDStudio.custom(pool="ABCDEF1234567890", count=2, length=16, hyphens=True)
|
|
194
|
+
print(f"Custom Hex: {custom_keys}")
|