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.1rc1.tar.gz
(132.9 kB
view hashes)
Built Distributions
Close
Hashes for pybase16384-0.2.1rc1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a03a99b4c7508db6e597b9782cea8a376f0015c251034fb88123d70caff3dfed |
|
MD5 | 85055cc44b64c72a110a6804115fb708 |
|
BLAKE2b-256 | 807a35188146ba4844b1fa663fc515014f645e6220bb5879f1381632d22524a8 |
Close
Hashes for pybase16384-0.2.1rc1-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 396feda9eb2c022eb431a61be87f51042e55ab10337b8d9147b68622683b5880 |
|
MD5 | 9ff08fd86473b0681c94b898912d39ca |
|
BLAKE2b-256 | 08eea381234cef7b90526b5006724cb2daea7827b91e34d08d47437db40b9bc1 |
Close
Hashes for pybase16384-0.2.1rc1-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9780fcba3129b5a8388d46fd6fac57f9b920d96a4585b99a5df8bf04e87d4b5b |
|
MD5 | 067479db1125561d2ad7ee5050e7787a |
|
BLAKE2b-256 | f8618de3a75befad28d8aebea136c14d04bf8877a7c0de93ea2aa2e0652762f6 |
Close
Hashes for pybase16384-0.2.1rc1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7114d5436defbca7cc6a93da7a031f83b39a691f31cb50f54fff191d2ca33db1 |
|
MD5 | 4226e1775ce6264f93b8531dfa07a5f4 |
|
BLAKE2b-256 | 766172eea74b32ffa793635693f9413da5f67b3c9f4d7471798226651d7bbd00 |
Close
Hashes for pybase16384-0.2.1rc1-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44ab48a7687f1cada78caf9673db1c95bf7b341164748fe6053acf38b9c8ad09 |
|
MD5 | e75bd841e7b06df6465c55bbac157524 |
|
BLAKE2b-256 | 3b70edcc488f90bd1e29500db2146e35632b838ea6b5ce1c6885d49c469eba9b |
Close
Hashes for pybase16384-0.2.1rc1-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3455e72731b4683977887ec821aeb69318398a7e48b3e8b5532c77b57aba47e |
|
MD5 | dc0c26f5f021543ec2a3c9a4600a0781 |
|
BLAKE2b-256 | 5cf1bde0b33857ce17e8be0a935a466ea22e2f27097175e1e79632011f2926a7 |
Close
Hashes for pybase16384-0.2.1rc1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4cbf7a0d2edaea6ac21ba123664aa656650573ea82db5eb61182c62768171dab |
|
MD5 | 0321e7b0ae08d80e6b600f4a7f397c1e |
|
BLAKE2b-256 | 69a5a7b7482b30e237f789bd317702ca607e6be4549c83190450419982bc7fcf |
Close
Hashes for pybase16384-0.2.1rc1-cp38-cp38-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | db7f4347d4c9161e78a56e8836f9c5369db41ca522ed90336a5a277b15a61491 |
|
MD5 | 9ea391399174041c9b5fe56c193b6d5f |
|
BLAKE2b-256 | 34a0e6b4dd6d548e5eb915e4f31e153f1a21ba4c46fa4cd223a11c6df34787e1 |
Close
Hashes for pybase16384-0.2.1rc1-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 399af262f7c181e418fd4f0c534b027566680959258ea1e0dabf1c8b12bf588b |
|
MD5 | 252f14b24b62e482700b9d75953fdb47 |
|
BLAKE2b-256 | a9fcd491476eb2f41cb38196b0f408b04aa2882a163bf5528e3b0400fad2b65f |
Close
Hashes for pybase16384-0.2.1rc1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9cd26f44e26ba8f4cd57ec13c6cd33c4e98ff6784543708eefd03e8b7cb256a |
|
MD5 | de260327c85aa4dd05887f9723be64f2 |
|
BLAKE2b-256 | 639e31b7c5ea00be4e4458d6aba716c5bee0d49f256c08477f290703d9cfe034 |
Close
Hashes for pybase16384-0.2.1rc1-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 34b10d6985e6521fca92f332da99481ca4af68d17192b37a65585f1db663572c |
|
MD5 | 3b059ebd4e4a43bc49852fa373b6b412 |
|
BLAKE2b-256 | 3f7e657170d78eb7855daf765bb46ca171d4a7fe3e31798d62999a70efb4954b |
Close
Hashes for pybase16384-0.2.1rc1-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb567a807a0dd0e409299327ca0a80e079808413e128b76ffcc448a875d0b28e |
|
MD5 | c0c2dd32c51c12d916b0e1c2371b81c9 |
|
BLAKE2b-256 | 9b9ceb45c587de6d694306bee5e95941a6af4ea662b05a8278aef9c4c67b2d40 |
Close
Hashes for pybase16384-0.2.1rc1-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c489ed3067b7b80c1d8163ca8d15e98198682099459067df6b83ddbafdf91db8 |
|
MD5 | c8d06073fc9e0a30dca2c7bac9509c88 |
|
BLAKE2b-256 | 2a32fe60a724de32eba62ed44828eeae670ea357f84e0e313da4a5f95d74f312 |
Close
Hashes for pybase16384-0.2.1rc1-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 441340b13f939236d76b1162fd31400fe3c71cde676052f3ed226bbff0ea1ba9 |
|
MD5 | e938efea656c597bec4fbb9221173c4f |
|
BLAKE2b-256 | b212a2501dff94566ed01bf6b5b431965b145aee46d4be6e72ade00e24e20ee1 |
Close
Hashes for pybase16384-0.2.1rc1-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27a7c26073db3d03633376ce3c72853c16c2cdf28966320070ba0b55f925bfd8 |
|
MD5 | ac36ad40be3f67fe6070f13e39116fc7 |
|
BLAKE2b-256 | ed8e42270ab608fc16392c0d3861e4a5ed558d2d61f435b03bd525f78e6d5cbb |