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: ...
_decode
在解码b'='
开头的数据时不安全:解释器异常_encode_into
和_decode_into
直接操作缓冲区对象的底层指针,0拷贝,当然也和上面一样的问题,他们是没有检查的
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.2.2.tar.gz
(132.5 kB
view hashes)
Built Distributions
Close
Hashes for pybase16384-0.2.2-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | de6c84fff98daf26747971c0699c21dd432c69f63c46d415932fb87c07775cfd |
|
MD5 | 1da17253ae6a7e145bdb754b01ed95f1 |
|
BLAKE2b-256 | 0104e1b67e8894c20467cb7cdb2f3218caf092ad997145b8505daf44e8b079a2 |
Close
Hashes for pybase16384-0.2.2-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cfbdfd8483f0a83059d9d6f3ce0e492c6945ffa8dd0aab651b3989cdbbbe0b27 |
|
MD5 | 7fe86417f0dcb9e1ed577230196b93e7 |
|
BLAKE2b-256 | ef1f15a384c7b64ba852dc6797f3fc7a4bba2694f0931f5de87e44725a40bdfc |
Close
Hashes for pybase16384-0.2.2-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a56ad04dbbbf074369faef89452498f4ae42bb6e59c21476cc1698da5e4981e |
|
MD5 | bfdabfe27954eb56f0f2a129afb36728 |
|
BLAKE2b-256 | 4c329be88d92d846ee993f979042d60b9b2bda72787bd557af1bba4dde93a5eb |
Close
Hashes for pybase16384-0.2.2-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89afbdcafd44e936a7267273cf95bd5eca007787248497d34d3c3438c3074740 |
|
MD5 | 0c37b3ecd68f2db1b1001da04eea57cc |
|
BLAKE2b-256 | 3dc8080d1cf2cbd93331d8f1b9833a30402f46b6cc186f9a49537f083af85ee4 |
Close
Hashes for pybase16384-0.2.2-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04777451b6f8df1bfb9b3e46db5a7bd4ceac43e131277aaa07b65e431a91a3c6 |
|
MD5 | 3459d80715eef650e107dff2e81d3321 |
|
BLAKE2b-256 | 8c2b28fb399db2b8953cc4a9d72f4231e1871d9f0e322861bbdee44ba05776b1 |
Close
Hashes for pybase16384-0.2.2-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81a9fb55d6290d8f1122b758fe42a8ad01349750cb3b3448a45f1eabb2628b62 |
|
MD5 | cff0aae5dc0eb59fc0248cb348e8ce3f |
|
BLAKE2b-256 | 504d0d05a4d48a332392803cf46080b0407b8bbc5d69a9f2559426516da30494 |
Close
Hashes for pybase16384-0.2.2-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b7503cf5340aab525f491b08e171a38ab4306193ef7476bef122cf7fddfe852 |
|
MD5 | 61a95336643f04f90b1fba1e618ea84b |
|
BLAKE2b-256 | 0f5696d6d985c8a01c51388ce96a6765d622d7836a944ed49f8f6e7cf8cb6f10 |
Close
Hashes for pybase16384-0.2.2-cp38-cp38-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2bca6c01ce2f0cfac09277a3acbb02cba693ca3a259e38465b72744115370fb |
|
MD5 | 732dd9f4582488b9c30f21ab237a7fc2 |
|
BLAKE2b-256 | c61f8d6344ddb3999cd12db1952e4405120bbd833b62b923413f75c9731c7742 |
Close
Hashes for pybase16384-0.2.2-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 74edfb16e0cfdc697eebb53f75bf3635c5859ef9293d0c2e9855d9f8c5ffd7ab |
|
MD5 | c71fd9a002a4871306ba48a882dad644 |
|
BLAKE2b-256 | a2f9de4b37c35f4c64fde00ec741c5899b94532df29c9c36f601622c885530b0 |
Close
Hashes for pybase16384-0.2.2-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 977775441a7b79de1e05ddebd0b61e111f348204ca3b55b21a0e9fde986b4672 |
|
MD5 | 1e22eaa63b14ce7b9d61f36ca5236cab |
|
BLAKE2b-256 | ab2516b703a4803e5f3bedcc49df7786f116cb05a45b174eb32367ead5a5f9bb |
Close
Hashes for pybase16384-0.2.2-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d35f8a9325a0f488688b2f098568c995d553794935513e7afb640e8d3163cc1 |
|
MD5 | 0321d82de3e8548466558ff65949d406 |
|
BLAKE2b-256 | 7d7e513b5a1d44889f284341d70915ff5524bcbdfca961df9ff0913140ecb06f |
Close
Hashes for pybase16384-0.2.2-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71c441bc1abf475cea1f29fa4d7acb6e0f797e1fccd183aa6a4b35a41cda9eb2 |
|
MD5 | 1e2c0d0ad77c6103f96e6221a43a3a23 |
|
BLAKE2b-256 | 908ac283678a6e73e689d652a0a74b55ff3e41ea3a14f75353ad0e0d5da2ca5e |
Close
Hashes for pybase16384-0.2.2-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d8701df1c9cfebda8934cc13b81690ed1a7d7bcc7160ebbf808a728b824bec5d |
|
MD5 | 2d4cc8c670bb57eb4899aca7bef1d677 |
|
BLAKE2b-256 | 53cd6f122f8fbf2a4a43d08b0917c87e764063b62500554e49d1e71c48e54389 |
Close
Hashes for pybase16384-0.2.2-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f21ef497d2ad11bf9b0579bab1a256ded9abf126a613d340a75a86f40fba6e8 |
|
MD5 | 1bf0f1539de8bdb3facef5bee0586b2e |
|
BLAKE2b-256 | 17dc9a4eaa6d952d56ccba0b61de3b82ceda9aa82dfd3f04c1a438767c88d5de |
Close
Hashes for pybase16384-0.2.2-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e245a143a54b9ce5adcc9b755e330ef703f0661a6f2b04acf78bcdd5b25de7f4 |
|
MD5 | 6422e68d90d084423bb06da30f5f143c |
|
BLAKE2b-256 | 83465dbed9619b17aa35f221abf4fea9e4f9e326ed9aa7c83a58c3ee73ee962c |