Skip to content

Lightweight Dart package offering substring‐based compression (BetCompressor) and XOR‐rotate encryption (BetCipher) with a one‐line BetAlgo API for seamless compress-&-encrypt and decrypt-&-decompress workflows.

License

Notifications You must be signed in to change notification settings

unix14/bet_algo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bet_algo

pub version
License: MIT

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() via BetAlgo

Installation

dart pub add bet_algo

Usage

  1. Create a .env file at your project root:

    BET_ALGO_ENCRYPTION_KEY=Your_Super_Secret_Key
    
  2. 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');
    }
  3. 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 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.


Example

See example/bet_algo_example.dart for a full end-to-end demonstration.


Development

  1. Fork & clone this repo
  2. dart pub get
  3. Code lives under lib/src/ and exports via lib/src/bet_algo_base.dart
  4. Tests live under test/
  5. dart test
  6. Bump version & update CHANGELOG.md
  7. dart pub publish

CHANGELOG

See CHANGELOG.md for details on each release.


License

MIT © Eyal Yaakobi


Built and maintained by unix14

About

Lightweight Dart package offering substring‐based compression (BetCompressor) and XOR‐rotate encryption (BetCipher) with a one‐line BetAlgo API for seamless compress-&-encrypt and decrypt-&-decompress workflows.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages