vernam_cipher 1.0.0+1 copy "vernam_cipher: ^1.0.0+1" to clipboard
vernam_cipher: ^1.0.0+1 copied to clipboard

Dart implementation of Vernam Cipher

pub package

Dart implementation of Vernam Cipher.

Usage #

var vernam = vernamCipher(); // optional key
var encoded = vernam.encode(utf8.encode('This is example.'));
var cleartext = vernam.decode(encoded);

Encryption and decryption in the form of streams:

final enStream =
      Stream.value(utf8.encode('This is example.')).transform(vernam.encoder);

var output = File('path/to/file').openWrite();
await output.addStream(enStream);
output.close();

var input = File('path/to/file').openRead();
var cleartext = await input
  .transform(vernam.decoder)
  .transform(utf8.decoder)
  .fold(StringBuffer(),
      (StringBuffer buffer, String string) => buffer..write(string))
  .then((StringBuffer buffer) => buffer.toString());