bet_algo
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
Features
- 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
Installation
dart pub add bet_algo
Usage
-
Create a
.envfile 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);
Public API
Import:
import 'package:bet_algo/bet_algo.dart';
Exports:
abstract class Compressorabstract class Decompressorabstract class Encryptorabstract class Decryptorclass BetCompressor implements Compressor, Decompressorclass BetXorCipher implements Encryptor, Decryptorclass BetAlgo
See the API reference on pub.dev for full docs.
Example
See example/bet_algo_example.dart for a full end-to-end demonstration.
Development
- 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
CHANGELOG
See CHANGELOG.md for details on each release.
License
MIT © Eyal Yaakobi
Built and maintained by unix14
Libraries
- bet_algo
- More dartdocs go here.