Symmetric Cipher XOR

platform_info

A pure dart XOR cipher library, support encryption and decryption with or without a symmetric secret key.

Usage example

1. with a secret key
import 'package:xor_dart/xor_dart.dart';

void main() {
  var xor = Xor('_a_random_key_');

  var plain = 'You are so handsome!';
  var encode = xor.encode(plain);
  var decode = xor.decode(encode);

  print('>>> plain: $plain, encode: $encode, decode: $decode');
  print('>>> decryption result is correct: ${plain == decode}'); // true
}
2. without a secret key
import 'dart:convert';
import 'package:xor_dart/xor_dart.dart';

void main() {
  var content = '1234567890';
  var bytes = utf8.encode(content);

  // To bytes
  var en = CipherXor.encrypt(bytes);
  var de = CipherXor.decrypt(en);
  print('content: $bytes, encrypted: $en, decrypted: $de');

  // To strings
  var encrypted = CipherXor.encryptToBase64(content);
  var decrypted = CipherXor.decryptFromBase64(encrypted);
  print('content: $content, encrypted: $encrypted, decrypted: $decrypted');
  print('>>>>>>>> decryption result is correct:: ${content == decrypted}'); // true
}

License

MIT

Features and bugs

Please feel free to: request new features and bugs at the issue tracker

Libraries

xor_dart