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.1.tar.gz
(163.4 kB
view hashes)
Built Distributions
Close
Hashes for pybase16384-0.3.1-pp38-pypy38_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8ad7168c5e430aa790bd767a10cdfeab6a47c01d3a4d5a88f96612d241ad5f1 |
|
MD5 | db21f3d4a738506e12ae6da3985e2732 |
|
BLAKE2b-256 | 9d0519151b2a08b70fd39c002b5141a4263afa438ed805b5d709fbb2918f7fd8 |
Close
Hashes for pybase16384-0.3.1-pp38-pypy38_pp73-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce67fdd6f2c5fe8198fe1235e48ac4551944a02c9d63b5bde487aab3a4caee6c |
|
MD5 | f6b28e25ee9391e3cb6e4c13de0ad9d9 |
|
BLAKE2b-256 | 6a162b098a688e9ffaffe66b1b251fc61223dec5590582f86178d5127c67f1d1 |
Close
Hashes for pybase16384-0.3.1-pp38-pypy38_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2422848102cbde3eed3f2793eda2a37bd9ab33900c274254951f18e6b3f8d9d5 |
|
MD5 | fbc0597fa03c5048f13a271b5d7c5be4 |
|
BLAKE2b-256 | 3be8700d691f9a8b971fc66acf701eead7772ed9b4667f6ab17534a8049d0889 |
Close
Hashes for pybase16384-0.3.1-pp37-pypy37_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b63cb727c553ca9005bd403dbea15176a7f38cc0764b63533af0b85f4f79d6a |
|
MD5 | a51be5c8f3fc6a9be4c0d8012bf64b15 |
|
BLAKE2b-256 | af4cee33834351d1a2f1cc11004d86ba5e56b240abd3f12e53b80261ad510c6b |
Close
Hashes for pybase16384-0.3.1-pp37-pypy37_pp73-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8476ac48da4c1dd288750380e77ab93979f71c01a0448d6f5b731ec4e70880a7 |
|
MD5 | b84484296c94c551431e3efbb8105f49 |
|
BLAKE2b-256 | 03a4d5218910c7413d0e3a2f908bdad632ceec2c2c6164afb63e5d6771e89c2a |
Close
Hashes for pybase16384-0.3.1-pp37-pypy37_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0bb001589771363f3cba5fdd7e0206be92ddfa66d9329ec62d105ce3f1c8fb61 |
|
MD5 | 4c7bbdc38ad13d050aa879ac40c0ec2a |
|
BLAKE2b-256 | 1f2a071cf091207242b920891b537d946d65ec5b52cfbaa7ec9bb2befa6a51be |
Close
Hashes for pybase16384-0.3.1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff24ae93a4bb1199f98215df66caa939431f02d4aeb568101a53dd50441b9eae |
|
MD5 | 97cfea6af91be1860a9d50946c4b2291 |
|
BLAKE2b-256 | 3a67da83c118188db20ee97059c682331105a38fd8cc4d7f61a70cdcf77dc5fe |
Close
Hashes for pybase16384-0.3.1-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21cbb8e0b64b376ceaba0c77443e7e471842c2afe638b58dc739eebc123c68ec |
|
MD5 | 72a5837d88e3f861451d0d30d524e2ee |
|
BLAKE2b-256 | f57a5d8c3c5a29ec25463f33a0c366e08b80d9dddd83f44e346e201575ffb2c8 |
Close
Hashes for pybase16384-0.3.1-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bfa2f5ef6f0aa92d70b41fddaf33bb3b4e87a3007744be8a65aaa9eb4be05dfa |
|
MD5 | 463231971ce2e5b5e3814694a99d274f |
|
BLAKE2b-256 | 712d19ccd037f2ec3d204c52fed8941c71e55c9d0243b3f27dd774bf860fe583 |
Close
Hashes for pybase16384-0.3.1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72eab2bc5c06c31fa4163133a017bd15d9cb43eb79ca95c94ca8e96a8d93b60c |
|
MD5 | 910cb2ef476f3b47a6ac55786800d02a |
|
BLAKE2b-256 | ef15020aa7c55aea19d7deed01429d902577f2c67b58e0365339400032edfb6f |
Close
Hashes for pybase16384-0.3.1-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b07945b7b9c987d3f538d2e7b5e9cd5a836b18450bdc23bacad5b59e7ecf8a8d |
|
MD5 | 5066672e3f321f285ecca934d7f1b6e8 |
|
BLAKE2b-256 | 99b07581c730dbe02631583c5c92a3a9d0adbc741fc32dd3d5f3f46ec95e0ef0 |
Close
Hashes for pybase16384-0.3.1-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b73659dcc1cdacc7a7e03747622fe0447b20fff76ef70d8609db53cc7358b7f7 |
|
MD5 | 04a04610b238326b6a380efb9f8a31a3 |
|
BLAKE2b-256 | 398c07825412698304c00e454d9464fde2fac09527ccae7de954759c3b879d8a |
Close
Hashes for pybase16384-0.3.1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 45f685b889694d1826124ffc9f383a08dce12183943036320e718e83710f3d1b |
|
MD5 | 30c188a51075d9f84f7eca0e117fb27e |
|
BLAKE2b-256 | ea33ffa891ae601bcc3e07f81ff965127d0fb213797ca3bb5ffa846a0c4c7213 |
Close
Hashes for pybase16384-0.3.1-cp38-cp38-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b716b1ff5353e213b39edf603d46d200e5765b6a00f6953f20e146e73b80c07a |
|
MD5 | a3475a3952b9680df095756e4eefd3a3 |
|
BLAKE2b-256 | f9023a56ea356bbc8356e05ac93e83d4f1b763657b847ddc61f5735a265b98a7 |
Close
Hashes for pybase16384-0.3.1-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6e63ecc2e2fa72bf496e441cf0c7fc2629da404b7acc00c4d8a5f565e6ded53 |
|
MD5 | 1a0ad15f6fee503103082161f9a087e5 |
|
BLAKE2b-256 | 307f0ef10bac56fbc84702ed1ed01e826bb1dbab39db40e28ba94cf45812cc78 |
Close
Hashes for pybase16384-0.3.1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b101900b7ceba96e94d7fd7953a21ea77e6746fc1f3c9b8a3793dce7068e64c4 |
|
MD5 | d911ef3d69623e6dd19c6ea57a7ac3b3 |
|
BLAKE2b-256 | fcfe885f0869f28c1d6dcda8ab9915b7d3581defe567beb034dfcb19d55657a5 |
Close
Hashes for pybase16384-0.3.1-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a927fe48d22e009b88feaf1028eb1ae566b7392714531119324f71866e05ee2 |
|
MD5 | 2d62700663ced1c70c91f4ff7197e42f |
|
BLAKE2b-256 | 8cd65a95109830c0f3bd569ab242331b303a0654cfb97ffa2d32834b3bd3846b |
Close
Hashes for pybase16384-0.3.1-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aec56e5790b878c246038d689435088cce19c26628a03b0eb34a352729c320c0 |
|
MD5 | eac479ab6713d5da38676c2f072f8610 |
|
BLAKE2b-256 | 162e10725be96eab672015031a6cb4923d4fe0fd103d902b338caac1461caabc |
Close
Hashes for pybase16384-0.3.1-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f1de10e571b6f62979163fe0139beeafe09b16d37546d0c0c90822c9c9cbb44 |
|
MD5 | 75d32821376f8f7ef485374001b268d7 |
|
BLAKE2b-256 | 892800b05dbb2e5e0cf5bd264f8d54f5b775c64057e56b84d556464ab4d6151d |
Close
Hashes for pybase16384-0.3.1-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b5b33cbe43382f92a3733498dcccb7573495e67abc168bd4f708a06004dbbb5c |
|
MD5 | 1b37d68c972cdd85080a61654eb1f4d8 |
|
BLAKE2b-256 | 18dd3752512ee100f6c23a0871527a47ce2a824d9aa19309538bc930e5756c5d |
Close
Hashes for pybase16384-0.3.1-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ebfd1618c5d2c72b39d3b698ecd44ba42eecdc171eae32a6f666dbb6eeb65a3 |
|
MD5 | 3534cb36aa80860fc51a1dbffe54d1c4 |
|
BLAKE2b-256 | 965b7fdade37fe48862f631f6d19638353099fb3f3428aea6ed09fbc7ac74518 |