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.0.dev1.tar.gz
(137.1 kB
view hashes)
Built Distributions
Close
Hashes for pybase16384-0.3.0.dev1-pp38-pypy38_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c968bf14a7c88ff7b48bca7342ebb6db627580549b80a925ef083d23a5db533a |
|
MD5 | 3387911cb9dd6561c94262d4ad68960a |
|
BLAKE2b-256 | adc9e9b6b7b895d322aad7b90e73c0ebaa5e79db1b033c66c050de600c579b43 |
Close
Hashes for pybase16384-0.3.0.dev1-pp38-pypy38_pp73-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6e9437d9aafbe5460fdabd90d5297fad19ac6c15b5b150117813a4d4b49462c |
|
MD5 | d7210a2fc591d7db7fef47ce67cee791 |
|
BLAKE2b-256 | 654dc148c899c0eb560cd5c636ac5d85fea16b25fc24ba1382209ec992419b86 |
Close
Hashes for pybase16384-0.3.0.dev1-pp38-pypy38_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 761e56a7e8300cfcc26b6b707f99ec7d49ca2e48b0268be14e48faab21687109 |
|
MD5 | adc4ba17fac9b88c15ba0e6543952cc2 |
|
BLAKE2b-256 | ab54cb1c23866dbf52a18806ab89f8e6b2cf7d994a15e2f810bcd99668b1af8a |
Close
Hashes for pybase16384-0.3.0.dev1-pp37-pypy37_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 609557a223fbb77cb99a5a4f8b2c4e155b53db3634bd3d59dc1c24970a5e3b43 |
|
MD5 | 0ff74c0307fb229510cfea5940acaca7 |
|
BLAKE2b-256 | 6dfffde0d419b7691533a84b579afdd33ddcf36f795e92ce0eb2bd3e1e68191c |
Close
Hashes for pybase16384-0.3.0.dev1-pp37-pypy37_pp73-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d58540089fd609d9638e42d6c0cadb8052a319df44882ef02036f74ca2e508eb |
|
MD5 | f0a20de82a85819521cd2ea143a31f48 |
|
BLAKE2b-256 | fdeda4c052b977601bb0f91058195bd0a0c6acbd971e780692b059f94ab78022 |
Close
Hashes for pybase16384-0.3.0.dev1-pp37-pypy37_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 982d4385e431a5c94e4cfc707afc6f9c76b38da6eb5a09eda5841c1aa2204f11 |
|
MD5 | 00a42049d29b0a99da1a8972f7186a15 |
|
BLAKE2b-256 | 5d19699cde0ad41ae871e97036f1a94638da6cf0ba088d22eb644bdefce0ad4a |
Close
Hashes for pybase16384-0.3.0.dev1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5e3407ed02356e2c9d75405e72b0c3d7679668dafd3b7d86bcf45a4eb8bb15c |
|
MD5 | ceb3558bfec1320cc206c5017c744869 |
|
BLAKE2b-256 | 725dd65a48b0a81828f4c82622d819ff55bbf09ba0890582c3a8b807f6f6d1d7 |
Close
Hashes for pybase16384-0.3.0.dev1-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f4f302a94b5d8d28dd676a242b0c0dab366cb05b4461f26c618f9827036e39c |
|
MD5 | a1d48bcc9080e5d2806aea7a091c1460 |
|
BLAKE2b-256 | 7fe7b3eefcffbad85d083b44a4bf62213d601e14877802fc364becca583e2e98 |
Close
Hashes for pybase16384-0.3.0.dev1-cp310-cp310-macosx_10_15_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52ce880d9c5f6a4ef0cc839b422ffb270ecc698e831fd8651de1bf9a1513539f |
|
MD5 | a67129b62ce187889679589b5aa12cc6 |
|
BLAKE2b-256 | 637f7983ad4508a290543d5ab9e7fd4f3c7a820e831e700bbb7e3a152248759e |
Close
Hashes for pybase16384-0.3.0.dev1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64407cdad0cd48df45e41865fd497031e19d0389056a8568b267dfe7dafc0888 |
|
MD5 | e1ed99505f2a73de46c0ca45b831b89c |
|
BLAKE2b-256 | 763debbae9ab8b9113cd227ee8068562a7b02e62c508df1d9475cb7f9f36e7d2 |
Close
Hashes for pybase16384-0.3.0.dev1-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22611045dc1a1a4de70abd235d6c92c1e7be706b9508359e81c0be867506aca8 |
|
MD5 | e7eabbc8692afaf5605ca4f542858c8e |
|
BLAKE2b-256 | c48bbb6feba2627b331d07e756e822965d29b3854b92233f190bef7c2875d916 |
Close
Hashes for pybase16384-0.3.0.dev1-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 959fe0513e80f743e280f63a9b859d6eb357994221ad79edae08c5d65b65f58d |
|
MD5 | 3863133c85edce11d0f011fd3f50d66a |
|
BLAKE2b-256 | 30074de6259e5844c17d5d1a74d3c5400a2e4dc7d458f922832c54c7f5ac4771 |
Close
Hashes for pybase16384-0.3.0.dev1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4f8a57ef989c452533c7246d1f4d4a15f498bbefa07c367c0415c9e896b233e |
|
MD5 | 7beb57f43d8aa0827ab39037873afbfd |
|
BLAKE2b-256 | 0452ff8270f5fdf7a5d605c65429e92d994003c183a27abbe0b92b598ca8b9c6 |
Close
Hashes for pybase16384-0.3.0.dev1-cp38-cp38-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4bc4389bb356f3f6967a185de1dc2903afca34d4eb12c4211b516cc8ad14b633 |
|
MD5 | a0cf24a06216bba6d40be2ce55356db6 |
|
BLAKE2b-256 | 6f97cfc63c9ab603145657a3e6f6af5c38ce5c964981eddca7c898aaf8acd7dd |
Close
Hashes for pybase16384-0.3.0.dev1-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae66d90832d1cefb79b8f5f0347743d2219f629b537379a8f532f0de4618e32b |
|
MD5 | 1c68510fdeea157e60a9645be6e8cb7d |
|
BLAKE2b-256 | 7bd98560d43121f5d9925ea7b55e43f8654e1818b5b6a0dc9c1b48c5e341ab98 |
Close
Hashes for pybase16384-0.3.0.dev1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96fef725994c4f5024d70da983a4a8d47784e9a75a731186da1172ba3696a30d |
|
MD5 | a1e3a4d7923c0fa2120d68a23025cef8 |
|
BLAKE2b-256 | 44b70b7f4074674274aed0a102bbe4875ca1c14484db957cca12672cdf09d90c |
Close
Hashes for pybase16384-0.3.0.dev1-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54d864dca3b02d50c0e5c53b55dd614cea5aa05bddb2fcb1ef90fc9290d3e774 |
|
MD5 | 5feda1242748d00d39ddba62d7916081 |
|
BLAKE2b-256 | b3e7bf692e03a15407e5768e2e31f75f826f64e3a09fb96d4a2d31f8482a7102 |
Close
Hashes for pybase16384-0.3.0.dev1-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b98d4ebe2e77b804b40d0da776ecc0e992d5011b46b719bde559233e7b6d5a3 |
|
MD5 | 0b3930e7a3b8757e98e30c2e6e6813c9 |
|
BLAKE2b-256 | 22eafbe1221bd03e8d49e88eb239ffb310b473ad2175cedc7a48728a62c6a884 |
Close
Hashes for pybase16384-0.3.0.dev1-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fcd4cbbcde0a6514e6447465e642986a23737dbf35c4b7d06d1fc181814f2710 |
|
MD5 | eb1e06c373e334712f4469f18b2b7d6a |
|
BLAKE2b-256 | bd90efe6cbcf780484a47f5bbf94ff2f1f9fc7d3d03beb168287e93f4ce772a3 |
Close
Hashes for pybase16384-0.3.0.dev1-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 721cf03f3499ed1f525354c558327269305376553c6587cf2796bbcecac7717c |
|
MD5 | d3af8ac80e5c8f42321205a2683de22d |
|
BLAKE2b-256 | a600a812bc694dc4927a052c54c07535af13bb7b9a639cf0502edd7090f2cfb8 |
Close
Hashes for pybase16384-0.3.0.dev1-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79f21be6992851e6751d67cb70ca8af5cf966275ca564d1b903626ec00dd750a |
|
MD5 | c49aa604861b9f18fe83d1b2b5d7c3d4 |
|
BLAKE2b-256 | e0e2695df62b2148574c83dfbfa2abfff0a7c40f981ffe38c05a489732d56a82 |