pybase16384 0.3.9__cp312-cp312-musllinux_1_2_aarch64.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.
@@ -0,0 +1,113 @@
1
+ # cython: language_level=3
2
+ # cython: cdivision=True
3
+ from libc.stdint cimport int32_t
4
+ from libc.stdio cimport FILE
5
+
6
+
7
+ cdef extern from "base16384.h" nogil:
8
+ int BASE16384_ENCBUFSZ
9
+ int BASE16384_DECBUFSZ
10
+
11
+ int BASE16384_FLAG_NOHEADER
12
+ int BASE16384_FLAG_SUM_CHECK_ON_REMAIN
13
+ int BASE16384_FLAG_DO_SUM_CHECK_FORCELY
14
+
15
+ ctypedef enum base16384_err_t:
16
+ base16384_err_ok
17
+ base16384_err_get_file_size
18
+ base16384_err_fopen_output_file
19
+ base16384_err_fopen_input_file
20
+ base16384_err_write_file
21
+ base16384_err_open_input_file
22
+ base16384_err_map_input_file
23
+ base16384_err_read_file
24
+ base16384_err_invalid_file_name
25
+ base16384_err_invalid_commandline_parameter
26
+ base16384_err_invalid_decoding_checksum
27
+ # encode_len calc min buf size to fill encode result
28
+ int b14_encode_len "base16384_encode_len" (int dlen)
29
+ # decode_len calc min buf size to fill decode result
30
+ int b14_decode_len "base16384_decode_len" (int dlen, int offset)
31
+
32
+ int b14_encode_safe "base16384_encode_safe" (const char * data, int dlen, char * buf)
33
+ # encode data and write result into buf
34
+ int b14_encode "base16384_encode" (const char* data, int dlen, char* buf)
35
+
36
+ int b14_encode_unsafe "base16384_encode_unsafe" (const char * data, int dlen, char * buf)
37
+ # decode data and write result into buf
38
+ int b14_decode_safe "base16384_decode_safe" (const char * data, int dlen, char * buf)
39
+
40
+ int b14_decode "base16384_decode" (const char* data, int dlen, char* buf)
41
+
42
+ int b14_decode_unsafe "base16384_decode_unsafe"(const char * data, int dlen, char * buf)
43
+
44
+ base16384_err_t b14_encode_file "base16384_encode_file" (const char * input, const char * output, char * encbuf, char * decbuf)
45
+ base16384_err_t b14_decode_file "base16384_decode_file" (const char * input, const char * output, char * encbuf, char * decbuf)
46
+
47
+ base16384_err_t b14_encode_fp "base16384_encode_fp" (FILE* input, FILE* output, char* encbuf, char* decbuf)
48
+
49
+ # base16384_encode_fd encodes input fd to output fd.
50
+ # encbuf & decbuf must be no less than BASE16384_ENCBUFSZ & BASE16384_DECBUFSZ
51
+ base16384_err_t b14_encode_fd "base16384_encode_fd" (int input, int output, char* encbuf, char* decbuf)
52
+
53
+
54
+ # base16384_decode_fp decodes input file to output file.
55
+ # encbuf & decbuf must be no less than BASE16384_ENCBUFSZ & BASE16384_DECBUFSZ
56
+ base16384_err_t b14_decode_fp "base16384_decode_fp"(FILE* input, FILE* output, char* encbuf, char* decbuf)
57
+
58
+ # base16384_decode_fd decodes input fd to output fd.
59
+ # encbuf & decbuf must be no less than BASE16384_ENCBUFSZ & BASE16384_DECBUFSZ
60
+ base16384_err_t b14_decode_fd "base16384_decode_fd"(int input, int output, char* encbuf, char* decbuf)
61
+
62
+ # detailed
63
+ # base16384_encode_file_detailed encodes input file to output file.
64
+ # use `-` to specify stdin/stdout
65
+ # encbuf & decbuf must be no less than BASE16384_ENCBUFSZ & BASE16384_DECBUFSZ
66
+ base16384_err_t b14_encode_file_detailed "base16384_encode_file_detailed" (const char* input, const char* output, char* encbuf, char* decbuf, int flag)
67
+
68
+ # base16384_encode_fp_detailed encodes input file to output file.
69
+ # encbuf & decbuf must be no less than BASE16384_ENCBUFSZ & BASE16384_DECBUFSZ
70
+ base16384_err_t b14_encode_fp_detailed "base16384_encode_fp_detailed" (FILE* input, FILE* output, char* encbuf, char* decbuf, int flag)
71
+
72
+ # base16384_encode_fd_detailed encodes input fd to output fd.
73
+ # encbuf & decbuf must be no less than BASE16384_ENCBUFSZ & BASE16384_DECBUFSZ
74
+ base16384_err_t b14_encode_fd_detailed "base16384_encode_fd_detailed" (int input, int output, char* encbuf, char* decbuf, int flag)
75
+
76
+ # base16384_decode_file_detailed decodes input file to output file.
77
+ # use `-` to specify stdin/stdout
78
+ # encbuf & decbuf must be no less than BASE16384_ENCBUFSZ & BASE16384_DECBUFSZ
79
+ base16384_err_t b14_decode_file_detailed "base16384_decode_file_detailed" (const char* input, const char* output, char* encbuf, char* decbuf, int flag)
80
+
81
+ # base16384_decode_fp_detailed decodes input file to output file.
82
+ # encbuf & decbuf must be no less than BASE16384_ENCBUFSZ & BASE16384_DECBUFSZ
83
+ base16384_err_t b14_decode_fp_detailed "base16384_decode_fp_detailed" (FILE* input, FILE* output, char* encbuf, char* decbuf, int flag)
84
+
85
+ # base16384_decode_fd_detailed decodes input fd to output fd.
86
+ # encbuf & decbuf must be no less than BASE16384_ENCBUFSZ & BASE16384_DECBUFSZ
87
+ base16384_err_t b14_decode_fd_detailed "base16384_decode_fd_detailed" (int input, int output, char* encbuf, char* decbuf, int flag)
88
+ # stream
89
+ ctypedef ssize_t (*base16384_reader_t) (const void *client_data, void *buffer, size_t count) except -100
90
+ ctypedef ssize_t (*base16384_writer_t) (const void *client_data, const void *buffer, size_t count) except -100
91
+
92
+ ctypedef union base16384_io_function_t:
93
+ base16384_reader_t reader
94
+ base16384_writer_t writer
95
+
96
+ ctypedef struct base16384_stream_t:
97
+ base16384_io_function_t f
98
+ void* client_data
99
+
100
+ base16384_err_t b14_encode_stream "base16384_encode_stream"(base16384_stream_t* input, base16384_stream_t* output, char* encbuf, char* decbuf)
101
+ base16384_err_t b14_encode_stream_detailed "base16384_encode_stream_detailed"(base16384_stream_t* input, base16384_stream_t* output, char* encbuf, char* decbuf, int flag)
102
+ base16384_err_t b14_decode_stream "base16384_decode_stream"(base16384_stream_t* input, base16384_stream_t* output, char* encbuf, char* decbuf)
103
+ base16384_err_t b14_decode_stream_detailed "base16384_decode_stream_detailed"(base16384_stream_t* input, base16384_stream_t* output, char* encbuf, char* decbuf, int flag)
104
+
105
+ cdef extern from * nogil:
106
+ """
107
+ #ifdef CPUBIT32
108
+ #define pybase16384_64bits() (0)
109
+ #else
110
+ #define pybase16384_64bits() (1)
111
+ #endif
112
+ """
113
+ int32_t pybase16384_64bits()
@@ -0,0 +1,216 @@
1
+ Metadata-Version: 2.4
2
+ Name: pybase16384
3
+ Version: 0.3.9
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: license-file
37
+ Dynamic: requires-dist
38
+ Dynamic: requires-python
39
+ Dynamic: summary
40
+
41
+ <h1 align="center"><i>✨ pybase16384 ✨ </i></h1>
42
+
43
+ <h3 align="center">The python binding for <a href="https://github.com/fumiama/base16384">base16384</a> </h3>
44
+
45
+ <h3 align="center"><i>一种神奇的编码 </i></h3>
46
+
47
+ [![pypi](https://img.shields.io/pypi/v/pybase16384.svg)](https://pypi.org/project/pybase16384/)
48
+ ![python](https://img.shields.io/pypi/pyversions/pybase16384)
49
+ ![implementation](https://img.shields.io/pypi/implementation/pybase16384)
50
+ ![wheel](https://img.shields.io/pypi/wheel/pybase16384)
51
+ ![license](https://img.shields.io/github/license/synodriver/pybase16384.svg)
52
+ ![action](https://img.shields.io/github/workflow/status/synodriver/pybase16384/build%20wheel)
53
+
54
+
55
+ ### 使用
56
+
57
+ - 编码/解码文本
58
+ ```python
59
+ >>> import pybase16384 as pybs
60
+ >>> pybs.encode_string('hello!!')
61
+ '栙擆羼漡'
62
+ >>> pybs.decode_string('栙擆羼漡')
63
+ 'hello!!'
64
+ ```
65
+
66
+ - 编码文件
67
+
68
+ ```python
69
+ from io import BytesIO
70
+
71
+ import pybase16384 as pybs
72
+
73
+ with open("input.pcm", "rb") as f:
74
+ data = f.read()
75
+ for i in range(1):
76
+ pybs.encode_file(BytesIO(data), open("output2.pcm", 'wb'), True)
77
+ ```
78
+ - 解码文件
79
+
80
+ ```python
81
+ from io import BytesIO
82
+
83
+ import pybase16384 as pybs
84
+
85
+ with open("output2.pcm", "rb") as f:
86
+ data = f.read()
87
+ for i in range(1):
88
+ pybs.decode_file(BytesIO(data), open("input2.pcm", 'wb'))
89
+ ```
90
+
91
+ ### 公开函数
92
+ ```python
93
+ from typing import IO
94
+
95
+ def encode_len(dlen: int) -> int: ...
96
+
97
+ def decode_len(dlen: int, offset: int) -> int: ...
98
+
99
+ ENCBUFSZ: int
100
+ DECBUFSZ: int
101
+ FLAG_NOHEADER: int
102
+ FLAG_SUM_CHECK_ON_REMAIN: int
103
+ FLAG_DO_SUM_CHECK_FORCELY: int
104
+
105
+ def is_64bits() -> bool: ...
106
+
107
+ def encode_file(input: IO, output: IO, write_head: bool = ..., buf_rate: int = ...): ...
108
+
109
+ def encode_file_safe(input: IO, output: IO, write_head: bool = ..., buf_rate: int = ...): ...
110
+
111
+ def decode_file(input: IO, output: IO, buf_rate: int = ...): ...
112
+
113
+ def decode_file_safe(input: IO, output: IO, buf_rate: int = ...): ...
114
+
115
+ def ensure_bytes(inp) -> bytes: ...
116
+
117
+ def encode_local_file(inp, out) -> None: ...
118
+
119
+ def decode_local_file(inp, out) -> None: ...
120
+
121
+ def encode_fd(inp: int, out: int) -> None: ...
122
+
123
+ def decode_fd(inp: int, out: int) -> None: ...
124
+
125
+ def encode_local_file_detailed(inp, out, flag: int) -> None: ...
126
+
127
+ def decode_local_file_detailed(inp, out, flag: int) -> None: ...
128
+
129
+ def encode_fd_detailed(inp: int, out: int, flag: int) -> None: ...
130
+
131
+ def decode_fd_detailed(inp: int, out: int, flag: int) -> None: ...
132
+
133
+ def encode(data: bytes) -> bytes: ...
134
+
135
+ def encode_safe(data: bytes) -> bytes: ...
136
+
137
+ def decode(data: bytes) -> bytes: ...
138
+
139
+ def decode_safe(data: bytes) -> bytes: ...
140
+
141
+ def encode_from_string(data: str, write_head: bool = ...) -> bytes: ...
142
+
143
+ def encode_from_string_safe(data: str, write_head: bool = ...) -> bytes: ...
144
+
145
+ def encode_to_string(data: bytes) -> str: ...
146
+
147
+ def encode_to_string_safe(data: bytes) -> str: ...
148
+
149
+ def encode_string(data: str) -> str: ...
150
+
151
+ def encode_string_safe(data: str) -> str: ...
152
+
153
+ def decode_from_bytes(data: bytes) -> str: ...
154
+
155
+ def decode_from_bytes_safe(data: bytes) -> str: ...
156
+
157
+ def decode_from_string(data: str) -> bytes: ...
158
+
159
+ def decode_from_string_safe(data: str) -> bytes: ...
160
+
161
+ def decode_string(data: str) -> str: ...
162
+
163
+ def decode_string_safe(data: str) -> str: ...
164
+
165
+ def encode_stream_detailed(inp, out, flag: int): ...
166
+
167
+ def decode_stream_detailed(inp, out, flag: int): ...
168
+ ```
169
+ - write_head将显式指明编码出的文本格式(utf16be),以便文本编辑器(如记事本)能够正确渲染,一般在写入文件时使用。
170
+
171
+ - buf_rate指定读取文件的策略。当它为n时,则表示一次读取7n或者8n个字节。如果读到的字节长度小于预期,则说明长度不够,
172
+ 此时,n将减半,恢复文件指针,重新读取。如果当n=1时长度仍然不够,就地encode/decode处理之。
173
+
174
+ - ```encode_len```和```decode_len```用于计算输出的长度
175
+
176
+ ### 内部函数
177
+
178
+ - 他们直接来自底层的C库,高性能,但是一般不需要在外部使用(除非是增加性能)
179
+
180
+ ```python
181
+ def _encode(data: BufferProtocol) -> bytes: ...
182
+
183
+ def _encode_safe(data: BufferProtocol) -> bytes: ...
184
+
185
+ def _decode(data: BufferProtocol) -> bytes: ...
186
+
187
+ def _decode_safe(data: BufferProtocol) -> bytes: ...
188
+
189
+ def _encode_into(data: BufferProtocol, dest: BufferProtocol) -> int: ...
190
+
191
+ def _encode_into_safe(data: BufferProtocol, dest: BufferProtocol) -> int: ...
192
+
193
+ def _decode_into(data: BufferProtocol, dest: BufferProtocol) -> int: ...
194
+
195
+ def _decode_into_safe(data: BufferProtocol, dest: BufferProtocol) -> int: ...
196
+
197
+ def is_64bits() -> bool: ...
198
+ ```
199
+ - ```_decode```在解码```b'='```开头的数据时***不安全***:***解释器异常***
200
+ - ```_encode_into```和```_decode_into```直接操作缓冲区对象的底层指针,0拷贝,当然也和上面一样的问题,他们是没有检查的
201
+
202
+ ### ✨ v0.3更新 ✨
203
+ 融合了 [CFFI](https://github.com/synodriver/pybase16384-cffi) 版本的成果,现在一个包可以同时在cpython和pypy上运行
204
+
205
+ ### 本机编译
206
+ ```
207
+ python -m pip install setuptools wheel cython cffi
208
+ git clone https://github.com/synodriver/pybase16384
209
+ cd pybase16384
210
+ git submodule update --init --recursive
211
+ python setup.py bdist_wheel --use-cython --use-cffi
212
+ ```
213
+ - 为了在windows上编译,需要加点料,把 [这个](https://gist.github.com/synodriver/8f1afae7b1a221754cb04ce417dc7e4d) 放进msvc的目录
214
+
215
+ ### 后端选择
216
+ 默认由py实现决定,在cpython上自动选择cython后端,在pypy上自动选择cffi后端,使用```B14_USE_CFFI```环境变量可以强制选择cffi
@@ -0,0 +1,16 @@
1
+ pybase16384/__init__.py,sha256=QxB65P3NQT4W-RumT_W1eX6yDKJoV-Ms2ALHSMqmsaQ,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=czl4_aohWox_VXRiNeH74Zwp9ZVUtDqXCHzvjeOKfEI,78048
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=x6r8Fw4CMLjgX8YyYFY_ATRQ6JCENWZm7vsxt1dp2hQ,302504
8
+ pybase16384/backends/cython/_core.c,sha256=KJPN3jGEL9tr1JTkm_l01kOj5TGPmDI5WaX6Mfiswp8,1588652
9
+ pybase16384/backends/cython/_core.pxi,sha256=2fXuRiumLqxO0bnmZVEz0lr_GX-grJGBfhGIVedfyt8,530
10
+ pybase16384/backends/cython/_core.pyx,sha256=OcY07Gk5n-9snqRCFrVTU-WhI8k1yiD6zcutRD5G1Dk,25159
11
+ pybase16384/backends/cython/base16384.pxd,sha256=HFGuEe2rXBWYw1vx74uaI7YATtkRGpcUAjANMRxPRFA,5942
12
+ pybase16384-0.3.9.dist-info/METADATA,sha256=2seC1dt201UqEyInOShzHT9VeNiRoaX_9FBFIK20teI,6858
13
+ pybase16384-0.3.9.dist-info/WHEEL,sha256=OhR_OrUHeSS9Wv6z5202HxeJVPkI7JBt4nUD2fey9No,113
14
+ pybase16384-0.3.9.dist-info/top_level.txt,sha256=kXpl7pWjnjpm74qJP0SJg3JhbiWuwKQApJgkJH0B5Mk,12
15
+ pybase16384-0.3.9.dist-info/RECORD,,
16
+ pybase16384-0.3.9.dist-info/licenses/LICENSE,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: false
4
+ Tag: cp312-cp312-musllinux_1_2_aarch64
5
+