A small Dart package providing:
- BetCompressor: a simple substring-replacement compressor
- BetXorCipher: XOR + bit-rotate encrypt/decrypt
- BetAlgo: a high-level API that chains compression → encryption and decryption → decompression
- Replaces repeated substrings (length ≥
minSubstringLength
) with short tokens - Serializes a dictionary + compressed data into JSON & Base64
- XOR-based encryption with rotating shifts from an externally supplied key
- One-step
compressAndEncrypt()
/decryptAndDecompress()
viaBetAlgo
dart pub add bet_algo
-
Create a
.env
file at your project root:BET_ALGO_ENCRYPTION_KEY=Your_Super_Secret_Key
-
Load & use
BetAlgo
:import 'package:bet_algo/bet_algo.dart'; void main() { final algo = BetAlgo.fromEnv( envFilePath: '.env', encryptionKeyEnvVar: 'BET_ALGO_ENCRYPTION_KEY', minSubstringLength: 3, ); const text = '…some repetitive or sensitive text…'; // compress & encrypt final token = algo.compressAndEncrypt(text); print('Token: $token'); // decrypt & decompress final out = algo.decryptAndDecompress(token); print('Recovered: $out'); }
-
Or use the components directly:
final compressor = BetCompressor(minSubstringLength: 2); final compressed = compressor.compress('aaabaaaab'); final roundtrip = compressor.decompress(compressed); final cipher = BetXorCipher('myKey'); final encrypted = cipher.encrypt('hello'); final decrypted = cipher.decrypt(encrypted);
Import:
import 'package:bet_algo/bet_algo.dart';
Exports:
abstract class Compressor
abstract class Decompressor
abstract class Encryptor
abstract class Decryptor
class BetCompressor implements Compressor, Decompressor
class BetXorCipher implements Encryptor, Decryptor
class BetAlgo
See the API reference on pub.dev for full docs.
See example/bet_algo_example.dart
for a full end-to-end demonstration.
- Fork & clone this repo
dart pub get
- Code lives under
lib/src/
and exports vialib/src/bet_algo_base.dart
- Tests live under
test/
dart test
- Bump version & update
CHANGELOG.md
dart pub publish
See CHANGELOG.md for details on each release.
MIT © Eyal Yaakobi
Built and maintained by unix14