BTD — Binary To Data: Ferramentas para salvar arquivos .btd
Project description
BTD (Binary To Data) — Ferramentas de Arquivo Binário
BTD é uma biblioteca leve em Python para salvar e carregar dados (texto ou dicionários) usando um formato binário personalizado com extensão .btd.
Utiliza criptografia XOR simples para proteger os dados e oferece funções auxiliares para manipulação binária.
📦 Instalação
pip install btd
---
⚙️ Funcionalidades Principais
save(data, path): Salva dados (str ou dict) no arquivo .btd.
load(path): Carrega dados do arquivo .btd, retornando str ou dict.
is_btd(path): Verifica se arquivo tem formato .btd válido.
split_chunks(data, size=1024): Divide bytes em pedaços menores de tamanho size.
get_size(data): Retorna o tamanho do dado criptografado.
to_bin(text): Converte texto em string binária (ex: '01101001 01101111').
from_bin(binary): Converte string binária de volta para texto.
---
🚀 Exemplo de Uso
from btd import BTD
btd = BTD(key=b"minhachave") # Pode usar chave personalizada para XOR
# Salvar texto e dicionário
btd.save("Olá, mundo!", "mensagem.btd")
btd.save({"nome": "Gabriel", "idade": "17"}, "dados.btd")
# Carregar arquivos
texto = btd.load("mensagem.btd") # retorna str
dados = btd.load("dados.btd") # retorna dict
print(texto) # Olá, mundo!
print(dados) # {'nome': 'Gabriel', 'idade': '17'}
# Verificar arquivo .btd válido
print(btd.is_btd("mensagem.btd")) # True
# Trabalhar com bytes
dados_bytes = texto.encode('utf-8')
partes = btd.split_chunks(dados_bytes, size=5)
print(partes) # [b'Ol\xc3\xa1,', b' mund', b'o!']
# Tamanho criptografado
print(btd.get_size("Exemplo"))
# Conversão texto-binário
binario = btd.to_bin("oi")
print(binario) # 01101111 01101001
texto2 = btd.from_bin(binario)
print(texto2) # oi
---
🔐 Sobre a Criptografia XOR
Os dados são criptografados com XOR usando uma chave que pode ser personalizada na criação do objeto BTD.
A chave padrão é b"mysecretkey".
---
📋 Requisitos
Python 3.7 ou superior
---
📝 Licença
MIT License — use, modifique e distribua livremente.
---
BTD (Binary To Data) — Binary File Tools
BTD is a lightweight Python library to save and load data (strings or dictionaries) using a custom binary format with .btd extension.
It uses simple XOR encryption to protect data and provides auxiliary functions for binary manipulation.
---
📦 Installation
pip install btd
---
⚙️ Main Features
save(data, path): Saves data (str or dict) into .btd file.
load(path): Loads data from .btd file, returns str or dict.
is_btd(path): Checks if a file is a valid .btd format.
split_chunks(data, size=1024): Splits bytes into smaller chunks of size.
get_size(data): Returns the size of encrypted data.
to_bin(text): Converts text to binary string (e.g. '01101001 01101111').
from_bin(binary): Converts binary string back to text.
---
🚀 Usage Example
from btd import BTD
btd = BTD(key=b"minhachave") # You can use a custom key for XOR
# Save string and dictionary
btd.save("Hello, world!", "message.btd")
btd.save({"name": "Gabriel", "age": "17"}, "data.btd")
# Load files
text = btd.load("message.btd") # returns str
data = btd.load("data.btd") # returns dict
print(text) # Hello, world!
print(data) # {'name': 'Gabriel', 'age': '17'}
# Check valid .btd file
print(btd.is_btd("message.btd")) # True
# Work with bytes
data_bytes = text.encode('utf-8')
parts = btd.split_chunks(data_bytes, size=5)
print(parts) # [b'Hello', b', wor', b'ld!']
# Encrypted size
print(btd.get_size("Example"))
# Text-binary conversion
binary = btd.to_bin("hi")
print(binary) # 01101000 01101001
text2 = btd.from_bin(binary)
print(text2) # hi
---
🔐 About XOR Encryption
Data is encrypted with XOR using a key that can be customized when creating the BTD object.
The default key is b"mysecretkey".
---
📋 Requirements
Python 3.7 or higher
---
📝 License
MIT License — use, modify and distribute freely.
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
btd-3.0.tar.gz
(4.7 kB
view details)
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
btd-3.0-py3-none-any.whl
(6.1 kB
view details)
File details
Details for the file btd-3.0.tar.gz.
File metadata
- Download URL: btd-3.0.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f8cee491bc95a8797cf2158fd21b5d115482fe7cfc9e38c309cbcea0bf5e663
|
|
| MD5 |
d8eed8f66abd48d364c7f430883bff56
|
|
| BLAKE2b-256 |
0ce1f36b5fde2f7d717310084d3b5af47d1379a030d69a1dac22768f29ce8cad
|
File details
Details for the file btd-3.0-py3-none-any.whl.
File metadata
- Download URL: btd-3.0-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9353c58051c5f2924950393a9f6399d0394bbe996f450daf249994d569719979
|
|
| MD5 |
5783d91618c4ef74ef6ab1c121c84e1a
|
|
| BLAKE2b-256 |
008eac3a0fa8feadafd1b143ae171cddc517d1bff011841e577366be02503820
|