base16384 encode and decode
Project description
✨ pybase16384 ✨
The python binding for base16384
一种神奇的编码
使用
- 编码/解码文本
>>> import pybase16384 as pybs
>>> pybs.encode_string('hello!!')
'栙擆羼漡'
>>> pybs.decode_string('栙擆羼漡')
'hello!!'
- 编码文件
from io import BytesIO
import pybase16384 as pybs
with open("input.pcm", "rb") as f:
data = f.read()
for i in range(1):
pybs.encode_file(BytesIO(data), open("output2.pcm", 'wb'), True)
- 解码文件
from io import BytesIO
import pybase16384 as pybs
with open("output2.pcm", "rb") as f:
data = f.read()
for i in range(1):
pybs.decode_file(BytesIO(data), open("input2.pcm", 'wb'))
公开函数
def encode_len(dlen: int) -> int: ...
def decode_len(dlen: int, offset: int) -> int: ...
def encode(data: bytes) -> bytes: ...
def decode(data: bytes) -> bytes: ...
def decode_file(input: BinaryIO, output: BinaryIO, buf_rate: int = 10) -> None: ...
def encode_file(input: BinaryIO, output: BinaryIO, boolwrite_head: bool = False, buf_rate: int = 10) -> None: ...
def encode_from_string(data: str, write_head: bool = False) -> bytes: ...
def encode_to_string(data: bytes) -> str: ...
def encode_string(data: str) -> str: ...
def decode_from_bytes(data: bytes) -> str: ...
def decode_from_string(data: str) -> bytes: ...
def decode_string(data: str) -> str: ...
-
write_head将显式指明编码出的文本格式(utf16be),以便文本编辑器(如记事本)能够正确渲染,一般在写入文件时使用。
-
buf_rate指定读取文件的策略。当它为n时,则表示一次读取7n或者8n个字节。如果读到的字节长度小于预期,则说明长度不够, 此时,n将减半,恢复文件指针,重新读取。如果当n=1时长度仍然不够,就地encode/decode处理之。
-
encode_len
和decode_len
用于计算输出的长度
内部函数
- 他们直接来自底层的C库,高性能,但是一般不需要在外部使用(除非是增加性能)
def _encode(data: BufferProtocol) -> bytes: ...
def _decode(data: BufferProtocol) -> bytes: ...
def _encode_into(data: BufferProtocol, dest: BufferProtocol) -> int: ...
def _decode_into(data: BufferProtocol, dest: BufferProtocol) -> int: ...
def is_64bits() -> bool: ...
_decode
在解码b'='
开头的数据时不安全:解释器异常_encode_into
和_decode_into
直接操作缓冲区对象的底层指针,0拷贝,当然也和上面一样的问题,他们是没有检查的
✨ v0.3更新 ✨
融合了 CFFI 版本的成果,现在一个包可以同时在cpython和pypy上运行
本机编译
python -m pip install setuptools wheel cython cffi
git clone https://github.com/synodriver/pybase16384
cd pybase16384
git submodule update --init --recursive
python setup.py bdist_wheel --use-cython --use-cffi
后端选择
默认由py实现决定,在cpython上自动选择cython后端,在pypy上自动选择cffi后端,使用B14_USE_CFFI
环境变量可以强制选择cffi
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pybase16384-0.3.0rc1.tar.gz
(161.5 kB
view hashes)
Built Distributions
Close
Hashes for pybase16384-0.3.0rc1-pp38-pypy38_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2491d78ae6fedcc851eff863307ed452334d560283617cf3a3d60086646e426 |
|
MD5 | 9d72c1be0a90b2ef1e7a5c9d5259607f |
|
BLAKE2b-256 | 9f9cdb1c0421d9c995c28972903712bdfd82862646081a2897fd5da9907b3930 |
Close
Hashes for pybase16384-0.3.0rc1-pp38-pypy38_pp73-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 223773f16dac8e0fe82163fa3bce0e3864b789493674fdfc0568f0e77ad0f36e |
|
MD5 | 1f46e2d966ada1000c0cd53978b4bdf2 |
|
BLAKE2b-256 | 2944e45326b4a1ff850f46250e4d83ff9722a2901c5247273b7ef0b3732827da |
Close
Hashes for pybase16384-0.3.0rc1-pp38-pypy38_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 535b41ca9f1769d28e15975bd570dc9fa99e47464f11d88c1ace0d60b49608df |
|
MD5 | 3759969990abe541dd3edf99975617db |
|
BLAKE2b-256 | c33e35cc1c6fae9a4345b040f05e045f034d1d6bbfcd65e932c1c6e1f7d083fd |
Close
Hashes for pybase16384-0.3.0rc1-pp37-pypy37_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cce0b8e710bbe01a7d237edad27b603928ee613f5a31af761b48afc2f080fc7d |
|
MD5 | 725e29f1318ac0c70b9923159714d283 |
|
BLAKE2b-256 | d9588b334536e4bd77fc7e8ecd4d86d14755ce7131d00596c7cdc9d30d877c3d |
Close
Hashes for pybase16384-0.3.0rc1-pp37-pypy37_pp73-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08011d632a68a57d11895b6492ab71bbba0de0d093480a374d2d830b2e3ee2b9 |
|
MD5 | 83b38bcd62c650d34a3623b6983c982f |
|
BLAKE2b-256 | 5f15f9ff574f2869285d945f1bac4c5336e45084f405ac0ca13823f197332d43 |
Close
Hashes for pybase16384-0.3.0rc1-pp37-pypy37_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02f388f18556e7a2a73ffadf33afddaa80fdab79c8908fb6f8e65ab4d4d750b0 |
|
MD5 | d8f3e8caeb5cc39c2b2b2562a91605e6 |
|
BLAKE2b-256 | d49903cd0335b4b7e0897456d9e71525947dc8e06a1ace28bf2d6b55f032db63 |
Close
Hashes for pybase16384-0.3.0rc1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 444b62bbe7dab2d1b75b5c5699aa9fb85b15d58823bbaa9895afbc1ca3d2f5d0 |
|
MD5 | 011cb330302e085115b29abff19855f1 |
|
BLAKE2b-256 | 12214f558178785ef57293ef15c2b3d0efcc5226359cad5de43fa0efe1f87bc1 |
Close
Hashes for pybase16384-0.3.0rc1-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e03eee788ca4ba762820f3777d375d1128a2c95be057de8803105361bd26741 |
|
MD5 | cb6a80e46cac56aa79317b7595adbc08 |
|
BLAKE2b-256 | 53055533dfedd18c86eae7c2d6c6fcef31d331c3e2000bb6beb2d49833addf02 |
Close
Hashes for pybase16384-0.3.0rc1-cp310-cp310-macosx_10_15_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 314b5e3a8833f0c3e67f29d14e5860e77f403caa76bf298da906e2804feff6c9 |
|
MD5 | c3a4c94340465bfa17ca11d4a1bcc809 |
|
BLAKE2b-256 | 4bf141fb05c39fca0dbbff3f83f881ab0d9a5645f66374ba56eed8e21f9e69b2 |
Close
Hashes for pybase16384-0.3.0rc1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff0028fe5099d4a09f987bd8e7e0d5015799e284243e7c6721fd52d4206fb9fd |
|
MD5 | 89cffc3508fdf4ad67fc54b999e11cf4 |
|
BLAKE2b-256 | 7389be55e95413fd4bb5157bb6c6e231cf679392da827b9677aa4d6f7ed4d55c |
Close
Hashes for pybase16384-0.3.0rc1-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07766799d6e3742237ce88df1cb3c28beb6bee154ca71d7ee8fead4180219cef |
|
MD5 | c026371bd91778b807b10cb407dd1d49 |
|
BLAKE2b-256 | 54ecc99f47473d478744f3ea692bb3aeaa7d32cf83829341ab2c8f66cdf8e023 |
Close
Hashes for pybase16384-0.3.0rc1-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 95ed2ebf18b61ad968d55d73af8808188bd70632fffe4fb3607fc9905595a509 |
|
MD5 | a714b4031f67c139adef2f00f859a557 |
|
BLAKE2b-256 | 5abd6c9ce3cfeaef8f1ba38325022501edccd1e360e1da86be1fd89026082535 |
Close
Hashes for pybase16384-0.3.0rc1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aceda09cf0e36c247d388c30c686d91d5da05e2cb1319146c86ac5edc3f422d3 |
|
MD5 | 8b4ced2857456e374c3af43e50110f9d |
|
BLAKE2b-256 | e4fd318e65e0be4e6182ad22574e221e1aac5023e4f5b73df8d6ce71a3c67a1b |
Close
Hashes for pybase16384-0.3.0rc1-cp38-cp38-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce94513397416c417281e852c931ff5e83538d352be8c3da576e2f4e1c1f0454 |
|
MD5 | 774e3f2e3e9f8eb563856cc49bb03ff7 |
|
BLAKE2b-256 | d5f485a7c202538bbeb493f9fa646251c75184c352b9ad50cb9de3df710771b9 |
Close
Hashes for pybase16384-0.3.0rc1-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b88eeff7239dd16a9bca626da4074e19d2fdffca16f5a64011da91705fa0cc3b |
|
MD5 | f2e76dbf1ad9ccb59a0b825314875d40 |
|
BLAKE2b-256 | eb413ee88051f535f415eda915640534f70ba751db65d165260ce9bb33367fec |
Close
Hashes for pybase16384-0.3.0rc1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 754e6ec69c17a3f026b9fcafd3da0c8b9a131dc0b3c7ea077ba650740b416310 |
|
MD5 | 3cfe29b6971202cf4f51dabdc1960bd4 |
|
BLAKE2b-256 | 6731c40c6972ac9147319db987dbdfdd0ffa474685eb68d0a69d6d2254c9de16 |
Close
Hashes for pybase16384-0.3.0rc1-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2958aebec506296bc138ff438c623ce37b570146d00cdcb8170f79d91a51dac3 |
|
MD5 | 1283e3e69dcc8a55b0c26615ccdb3130 |
|
BLAKE2b-256 | b3426e022f37260da78e4d2603a4b8d4a72793991139eb6b76fdd772fea4761b |
Close
Hashes for pybase16384-0.3.0rc1-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48ef1de5d42451c88a58aaa31adb2087a959afc26af10844d73ad413e0f98454 |
|
MD5 | 1e379a6abd159a8d9564aa5372ee3745 |
|
BLAKE2b-256 | 32c6f800d7ba8049ab3a4dc83a0c1e5bfc78762ea22dc8b4cc2c257014490a92 |
Close
Hashes for pybase16384-0.3.0rc1-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | de526ed54a14983d1e1ce608fc970788c8b4fdba12ea0e4f93f975f27abbc2bc |
|
MD5 | 3384981a4f2e5eb3dc175bf26f2cf01e |
|
BLAKE2b-256 | 890517acafe3d643247422a54f83c990345e6300b71ab84267443c55b19ffb71 |
Close
Hashes for pybase16384-0.3.0rc1-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee90a828c80180467d7d5300c856a2f41fac73056178010795eb1f25ebe10aad |
|
MD5 | f0ff5a88f33448f75b3e0ff81c549142 |
|
BLAKE2b-256 | 3b3861d39ab8830423f84e47d45ad5106fdb96b209bd563a51f5a9abebebbeb3 |
Close
Hashes for pybase16384-0.3.0rc1-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92d3d5c17ce96e6a74394eef16a5674dfc7870d86db75ed10305bf46f686dcd8 |
|
MD5 | e44a8a2be16ee8dad887308ac1388fda |
|
BLAKE2b-256 | 9f42677cae4c763666e054d10526319db779f1b69789898deaf1a0b8ef8e18ad |