obfuscate 1.0.1 copy "obfuscate: ^1.0.1" to clipboard
obfuscate: ^1.0.1 copied to clipboard

Dart CLI tool and library for text obfuscation and deobfuscation using custom mapping, Base64, ROT13, XOR, and string reversal.

example/obfuscate_example.dart

import 'package:obfuscate/obfuscate.dart';

void main() {
  const text = 'Hello, World!';
  print('Original: $text');

  // Base64
  const base64Codec = Base64ObfuscationCodec();
  final base64Obfuscated = base64Codec.obfuscate(text);
  print('Base64: $base64Obfuscated');
  print('Base64 Decoded: ${base64Codec.deobfuscate(base64Obfuscated)}');

  // ROT13
  const rot13Codec = Rot13Codec();
  final rot13Obfuscated = rot13Codec.obfuscate(text);
  print('ROT13: $rot13Obfuscated');
  print('ROT13 Decoded: ${rot13Codec.deobfuscate(rot13Obfuscated)}');

  // XOR (byte-safe: output is base64, key must be 0-255)
  final xorCodec = XorCodec(123);
  final xorObfuscated = xorCodec.obfuscate(text);
  print('XOR: $xorObfuscated');
  print('XOR Decoded: ${xorCodec.deobfuscate(xorObfuscated)}');

  // Reverse
  const reverseCodec = ReverseCodec();
  final reverseObfuscated = reverseCodec.obfuscate(text);
  print('Reverse: $reverseObfuscated');
  print('Reverse Decoded: ${reverseCodec.deobfuscate(reverseObfuscated)}');

  // Custom 1-char -> 1-char mapping (validated at construction time —
  // throws InvalidMapException immediately if the map isn't bijective)
  final customMap = {
    'h': 'x',
    'e': 'y',
    'l': 'z',
    'o': 'w',
    'r': 'a',
    'd': 'b',
  };
  final customCodec = SubstitutionCodec(customMap);
  final customObfuscated = customCodec.obfuscate(text);
  print('Custom Map: $customObfuscated');
  print('Custom Map Decoded: ${customCodec.deobfuscate(customObfuscated)}');

  // Custom 1-char -> word mapping (needs a delimiter, unmapped chars throw)
  final wordMap = {'h': 'house', 'e': 'energy', 'l': 'library', 'o': 'office'};
  final tokenCodec = TokenSubstitutionCodec(wordMap);
  final tokenObfuscated = tokenCodec.obfuscate('hello');
  print('Token Map: $tokenObfuscated');
  print('Token Map Decoded: ${tokenCodec.deobfuscate(tokenObfuscated)}');
}
4
likes
160
points
145
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Dart CLI tool and library for text obfuscation and deobfuscation using custom mapping, Base64, ROT13, XOR, and string reversal.

Repository (GitHub)
View/report issues

Topics

#cli #obfuscation #encryption #text-processing

License

MIT (license)

Dependencies

args

More

Packages that depend on obfuscate