pybase16384 0.3.8__cp313-cp313-musllinux_1_2_x86_64.whl
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.
Potentially problematic release.
This version of pybase16384 might be problematic. Click here for more details.
- pybase16384/__init__.py +205 -0
- pybase16384/backends/__init__.py +1 -0
- pybase16384/backends/cffi/__init__.py +463 -0
- pybase16384/backends/cffi/_core.abi3.so +0 -0
- pybase16384/backends/cffi/build.py +183 -0
- pybase16384/backends/cython/__init__.py +36 -0
- pybase16384/backends/cython/_core.abi3.so +0 -0
- pybase16384/backends/cython/_core.c +39876 -0
- pybase16384/backends/cython/_core.pxi +12 -0
- pybase16384/backends/cython/_core.pyx +619 -0
- pybase16384/backends/cython/base16384.pxd +113 -0
- pybase16384-0.3.8.dist-info/LICENSE +674 -0
- pybase16384-0.3.8.dist-info/METADATA +215 -0
- pybase16384-0.3.8.dist-info/RECORD +16 -0
- pybase16384-0.3.8.dist-info/WHEEL +5 -0
- pybase16384-0.3.8.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: pybase16384
|
|
3
|
+
Version: 0.3.8
|
|
4
|
+
Summary: fast base16384 encode and decode
|
|
5
|
+
Home-page: https://github.com/synodriver/pybase16384
|
|
6
|
+
Author: synodriver
|
|
7
|
+
Author-email: diguohuangjiajinweijun@gmail.com
|
|
8
|
+
License: GPLv3
|
|
9
|
+
Keywords: encode,decode,base16384
|
|
10
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
13
|
+
Classifier: Topic :: Security :: Cryptography
|
|
14
|
+
Classifier: Programming Language :: C
|
|
15
|
+
Classifier: Programming Language :: Cython
|
|
16
|
+
Classifier: Programming Language :: Python
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
23
|
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
24
|
+
Requires-Python: >=3.6
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Requires-Dist: cffi>=1.0.0
|
|
28
|
+
Dynamic: author
|
|
29
|
+
Dynamic: author-email
|
|
30
|
+
Dynamic: classifier
|
|
31
|
+
Dynamic: description
|
|
32
|
+
Dynamic: description-content-type
|
|
33
|
+
Dynamic: home-page
|
|
34
|
+
Dynamic: keywords
|
|
35
|
+
Dynamic: license
|
|
36
|
+
Dynamic: requires-dist
|
|
37
|
+
Dynamic: requires-python
|
|
38
|
+
Dynamic: summary
|
|
39
|
+
|
|
40
|
+
<h1 align="center"><i>✨ pybase16384 ✨ </i></h1>
|
|
41
|
+
|
|
42
|
+
<h3 align="center">The python binding for <a href="https://github.com/fumiama/base16384">base16384</a> </h3>
|
|
43
|
+
|
|
44
|
+
<h3 align="center"><i>一种神奇的编码 </i></h3>
|
|
45
|
+
|
|
46
|
+
[](https://pypi.org/project/pybase16384/)
|
|
47
|
+

|
|
48
|
+

|
|
49
|
+

|
|
50
|
+

|
|
51
|
+

|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
### 使用
|
|
55
|
+
|
|
56
|
+
- 编码/解码文本
|
|
57
|
+
```python
|
|
58
|
+
>>> import pybase16384 as pybs
|
|
59
|
+
>>> pybs.encode_string('hello!!')
|
|
60
|
+
'栙擆羼漡'
|
|
61
|
+
>>> pybs.decode_string('栙擆羼漡')
|
|
62
|
+
'hello!!'
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
- 编码文件
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
from io import BytesIO
|
|
69
|
+
|
|
70
|
+
import pybase16384 as pybs
|
|
71
|
+
|
|
72
|
+
with open("input.pcm", "rb") as f:
|
|
73
|
+
data = f.read()
|
|
74
|
+
for i in range(1):
|
|
75
|
+
pybs.encode_file(BytesIO(data), open("output2.pcm", 'wb'), True)
|
|
76
|
+
```
|
|
77
|
+
- 解码文件
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
from io import BytesIO
|
|
81
|
+
|
|
82
|
+
import pybase16384 as pybs
|
|
83
|
+
|
|
84
|
+
with open("output2.pcm", "rb") as f:
|
|
85
|
+
data = f.read()
|
|
86
|
+
for i in range(1):
|
|
87
|
+
pybs.decode_file(BytesIO(data), open("input2.pcm", 'wb'))
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 公开函数
|
|
91
|
+
```python
|
|
92
|
+
from typing import IO
|
|
93
|
+
|
|
94
|
+
def encode_len(dlen: int) -> int: ...
|
|
95
|
+
|
|
96
|
+
def decode_len(dlen: int, offset: int) -> int: ...
|
|
97
|
+
|
|
98
|
+
ENCBUFSZ: int
|
|
99
|
+
DECBUFSZ: int
|
|
100
|
+
FLAG_NOHEADER: int
|
|
101
|
+
FLAG_SUM_CHECK_ON_REMAIN: int
|
|
102
|
+
FLAG_DO_SUM_CHECK_FORCELY: int
|
|
103
|
+
|
|
104
|
+
def is_64bits() -> bool: ...
|
|
105
|
+
|
|
106
|
+
def encode_file(input: IO, output: IO, write_head: bool = ..., buf_rate: int = ...): ...
|
|
107
|
+
|
|
108
|
+
def encode_file_safe(input: IO, output: IO, write_head: bool = ..., buf_rate: int = ...): ...
|
|
109
|
+
|
|
110
|
+
def decode_file(input: IO, output: IO, buf_rate: int = ...): ...
|
|
111
|
+
|
|
112
|
+
def decode_file_safe(input: IO, output: IO, buf_rate: int = ...): ...
|
|
113
|
+
|
|
114
|
+
def ensure_bytes(inp) -> bytes: ...
|
|
115
|
+
|
|
116
|
+
def encode_local_file(inp, out) -> None: ...
|
|
117
|
+
|
|
118
|
+
def decode_local_file(inp, out) -> None: ...
|
|
119
|
+
|
|
120
|
+
def encode_fd(inp: int, out: int) -> None: ...
|
|
121
|
+
|
|
122
|
+
def decode_fd(inp: int, out: int) -> None: ...
|
|
123
|
+
|
|
124
|
+
def encode_local_file_detailed(inp, out, flag: int) -> None: ...
|
|
125
|
+
|
|
126
|
+
def decode_local_file_detailed(inp, out, flag: int) -> None: ...
|
|
127
|
+
|
|
128
|
+
def encode_fd_detailed(inp: int, out: int, flag: int) -> None: ...
|
|
129
|
+
|
|
130
|
+
def decode_fd_detailed(inp: int, out: int, flag: int) -> None: ...
|
|
131
|
+
|
|
132
|
+
def encode(data: bytes) -> bytes: ...
|
|
133
|
+
|
|
134
|
+
def encode_safe(data: bytes) -> bytes: ...
|
|
135
|
+
|
|
136
|
+
def decode(data: bytes) -> bytes: ...
|
|
137
|
+
|
|
138
|
+
def decode_safe(data: bytes) -> bytes: ...
|
|
139
|
+
|
|
140
|
+
def encode_from_string(data: str, write_head: bool = ...) -> bytes: ...
|
|
141
|
+
|
|
142
|
+
def encode_from_string_safe(data: str, write_head: bool = ...) -> bytes: ...
|
|
143
|
+
|
|
144
|
+
def encode_to_string(data: bytes) -> str: ...
|
|
145
|
+
|
|
146
|
+
def encode_to_string_safe(data: bytes) -> str: ...
|
|
147
|
+
|
|
148
|
+
def encode_string(data: str) -> str: ...
|
|
149
|
+
|
|
150
|
+
def encode_string_safe(data: str) -> str: ...
|
|
151
|
+
|
|
152
|
+
def decode_from_bytes(data: bytes) -> str: ...
|
|
153
|
+
|
|
154
|
+
def decode_from_bytes_safe(data: bytes) -> str: ...
|
|
155
|
+
|
|
156
|
+
def decode_from_string(data: str) -> bytes: ...
|
|
157
|
+
|
|
158
|
+
def decode_from_string_safe(data: str) -> bytes: ...
|
|
159
|
+
|
|
160
|
+
def decode_string(data: str) -> str: ...
|
|
161
|
+
|
|
162
|
+
def decode_string_safe(data: str) -> str: ...
|
|
163
|
+
|
|
164
|
+
def encode_stream_detailed(inp, out, flag: int): ...
|
|
165
|
+
|
|
166
|
+
def decode_stream_detailed(inp, out, flag: int): ...
|
|
167
|
+
```
|
|
168
|
+
- write_head将显式指明编码出的文本格式(utf16be),以便文本编辑器(如记事本)能够正确渲染,一般在写入文件时使用。
|
|
169
|
+
|
|
170
|
+
- buf_rate指定读取文件的策略。当它为n时,则表示一次读取7n或者8n个字节。如果读到的字节长度小于预期,则说明长度不够,
|
|
171
|
+
此时,n将减半,恢复文件指针,重新读取。如果当n=1时长度仍然不够,就地encode/decode处理之。
|
|
172
|
+
|
|
173
|
+
- ```encode_len```和```decode_len```用于计算输出的长度
|
|
174
|
+
|
|
175
|
+
### 内部函数
|
|
176
|
+
|
|
177
|
+
- 他们直接来自底层的C库,高性能,但是一般不需要在外部使用(除非是增加性能)
|
|
178
|
+
|
|
179
|
+
```python
|
|
180
|
+
def _encode(data: BufferProtocol) -> bytes: ...
|
|
181
|
+
|
|
182
|
+
def _encode_safe(data: BufferProtocol) -> bytes: ...
|
|
183
|
+
|
|
184
|
+
def _decode(data: BufferProtocol) -> bytes: ...
|
|
185
|
+
|
|
186
|
+
def _decode_safe(data: BufferProtocol) -> bytes: ...
|
|
187
|
+
|
|
188
|
+
def _encode_into(data: BufferProtocol, dest: BufferProtocol) -> int: ...
|
|
189
|
+
|
|
190
|
+
def _encode_into_safe(data: BufferProtocol, dest: BufferProtocol) -> int: ...
|
|
191
|
+
|
|
192
|
+
def _decode_into(data: BufferProtocol, dest: BufferProtocol) -> int: ...
|
|
193
|
+
|
|
194
|
+
def _decode_into_safe(data: BufferProtocol, dest: BufferProtocol) -> int: ...
|
|
195
|
+
|
|
196
|
+
def is_64bits() -> bool: ...
|
|
197
|
+
```
|
|
198
|
+
- ```_decode```在解码```b'='```开头的数据时***不安全***:***解释器异常***
|
|
199
|
+
- ```_encode_into```和```_decode_into```直接操作缓冲区对象的底层指针,0拷贝,当然也和上面一样的问题,他们是没有检查的
|
|
200
|
+
|
|
201
|
+
### ✨ v0.3更新 ✨
|
|
202
|
+
融合了 [CFFI](https://github.com/synodriver/pybase16384-cffi) 版本的成果,现在一个包可以同时在cpython和pypy上运行
|
|
203
|
+
|
|
204
|
+
### 本机编译
|
|
205
|
+
```
|
|
206
|
+
python -m pip install setuptools wheel cython cffi
|
|
207
|
+
git clone https://github.com/synodriver/pybase16384
|
|
208
|
+
cd pybase16384
|
|
209
|
+
git submodule update --init --recursive
|
|
210
|
+
python setup.py bdist_wheel --use-cython --use-cffi
|
|
211
|
+
```
|
|
212
|
+
- 为了在windows上编译,需要加点料,把 [这个](https://gist.github.com/synodriver/8f1afae7b1a221754cb04ce417dc7e4d) 放进msvc的目录
|
|
213
|
+
|
|
214
|
+
### 后端选择
|
|
215
|
+
默认由py实现决定,在cpython上自动选择cython后端,在pypy上自动选择cffi后端,使用```B14_USE_CFFI```环境变量可以强制选择cffi
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
pybase16384/__init__.py,sha256=xDOQ59rGsfkEhlODtzpqltiJmvTOMYT0puEhW6w8DBo,4897
|
|
2
|
+
pybase16384/backends/__init__.py,sha256=vdW_t1O2WNfdRmxDlEXRvTpyJj5ufKWAUsD2fbtku5g,55
|
|
3
|
+
pybase16384/backends/cffi/__init__.py,sha256=oGen7JI3AMlvsCjM8xF4k6zBK2v_QqQ5UsrdMVtD_Zo,15970
|
|
4
|
+
pybase16384/backends/cffi/_core.abi3.so,sha256=7mMFTLDL4YmQCR_klJQvP374IBWfGHqQeH_BF54BMvg,68592
|
|
5
|
+
pybase16384/backends/cffi/build.py,sha256=NyTK_W4JKJbqtdAS0yZ0sxkQvLDE8npjOskWN1-YOqk,5824
|
|
6
|
+
pybase16384/backends/cython/__init__.py,sha256=iqaf2DeavB1x_LnQi949Qqkrn00KAwG9xJMPVUdnIB8,738
|
|
7
|
+
pybase16384/backends/cython/_core.abi3.so,sha256=7EGFw_zBAyJJyEF2PV8glyeFxIebYhVJnmB3QMQ1-No,335088
|
|
8
|
+
pybase16384/backends/cython/_core.c,sha256=DYgK3iK54k9e1qiwPCd1bY9mWriqCvvimLN-ne5Icv4,1558556
|
|
9
|
+
pybase16384/backends/cython/_core.pyx,sha256=OcY07Gk5n-9snqRCFrVTU-WhI8k1yiD6zcutRD5G1Dk,25159
|
|
10
|
+
pybase16384/backends/cython/_core.pxi,sha256=2fXuRiumLqxO0bnmZVEz0lr_GX-grJGBfhGIVedfyt8,530
|
|
11
|
+
pybase16384/backends/cython/base16384.pxd,sha256=HFGuEe2rXBWYw1vx74uaI7YATtkRGpcUAjANMRxPRFA,5942
|
|
12
|
+
pybase16384-0.3.8.dist-info/LICENSE,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
|
|
13
|
+
pybase16384-0.3.8.dist-info/WHEEL,sha256=XPgYmeBC_Rg0MCVBgXqO165pafrAlEvfR4FBK_d_Vdw,112
|
|
14
|
+
pybase16384-0.3.8.dist-info/top_level.txt,sha256=kXpl7pWjnjpm74qJP0SJg3JhbiWuwKQApJgkJH0B5Mk,12
|
|
15
|
+
pybase16384-0.3.8.dist-info/METADATA,sha256=HKwiEO0_m8J4u1QmjLLz1c2j2ymgAgh4eNZJ58t_frA,6836
|
|
16
|
+
pybase16384-0.3.8.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pybase16384
|