QRST-AB or QRST is a QR code-based secure transmission algorithm (QRST-AB) using Avro and Byte Pair Encoding (BPE)
Project description
QRST-AB
QRST-AB or QRST is a QR code-based secure transmission algorithm (QRST-AB) using Avro and Byte Pair Encoding (BPE).
Installation
install by pip
pip install qrst
or install by source code
git clone https://github.com/DrBreath/QRST-AB
cd QRST-AB
python setup.py install
Get Start
The demonstration code for encoding and decoding with qrst is as follows:
from qrst import QR_Codec,write_qr2png,load_json
import json
qr_codec = QR_Codec('./tests/example/qr.codec.test.config.yml')
# Input JSON: Read a JSON file
obj = load_json('./tests/example/sample_en.json')
# Encode into different QR code data streams
qr_list = qr_codec.encode(obj)
# Decode and restore it back to JSON
patient_id = obj.pop(qr_codec.conf['identity_field'] )
for qr_bytes in qr_list:
flag,ret = qr_codec.decode(qr_bytes,patient_id)
print('flag=',flag)
if flag == 'finished':
print('ret=',ret)
# Test generating QR code images
write_qr2png(qr_list,'./temp')
# Calculate compression ratio
orig_size = len(json.dumps(obj).encode())
compressed_size = sum([len(q) for q in qr_list])
print(f'JSON file size = {orig_size}bytes, compressed siez = {compressed_size}bytes,Compressed Ratio={orig_size/compressed_size:.2f}')
-
the demo code see as : ./demo.py
-
the example of config see as : ./tests/example/qr.codec.test.config.yml
-
the example of test json file see as : ./tests/example/sample_en.json
Practical Suggestions:
- Refer to ./tests/example/qr.codec.test.config.yml to define your own JSON configuration file and
Apache Avro Schema - Using a private corpus to train a tokenizer can achieve better compression performance and prevent third-party decoding. For training methods, refer to sentencepiece
LICENSE
Apache License 2.0
Copyright [2024] [Changzhen Li]
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Additional Terms:
- This software is provided for academic, non-commercial use only.
- Any commercial use of this software requires prior written authorization from the author.
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 Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file qrst-0.1.0-py3-none-any.whl.
File metadata
- Download URL: qrst-0.1.0-py3-none-any.whl
- Upload date:
- Size: 17.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b82a99d3502c06bbd49bd5a438843053590f95acc7d9b4d24cf6bbd68ce31b77
|
|
| MD5 |
a73b281b94069e8c5cce8ae9c1ae6722
|
|
| BLAKE2b-256 |
8c76237b4e7c1e972a39ed0b24b43eb9a833c76c12651f332db49f302f225ab2
|