cipherlib 0.0.3 copy "cipherlib: ^0.0.3" to clipboard
cipherlib: ^0.0.3 copied to clipboard

retracted

Implementations of cryptographic algorithms for encryption and decryption in Dart.

cipherlib #

plugin version dependencies dart support likes pub points popularity

Implementations of cryptographic algorithms for encryption and decryption in Dart.

Features #

Ciphers Public class and methods Source
ChaCha20 ChaCha20, chacha20, chacha20Pipe RFC-8439
XOR XOR, xor, xorPipe Wikipedia

Getting started #

The following import will give you access to all of the algorithms in this package.

import 'package:cipherlib/cipherlib.dart';

Check the API Reference for details.

Usage #

Examples can be found inside the example folder.

import 'dart:convert';

import 'package:cipherlib/cipherlib.dart';
import 'package:hashlib_codecs/hashlib_codecs.dart';

void main() {
  print('----- XOR -----');
  {
    var key = [0x54];
    var inp = [0x03, 0xF1];
    var cipher = xor(inp, key);
    var plain = xor(cipher, key);
    print('  Text: ${toBinary(inp)}');
    print('   Key: ${toBinary(key)}');
    print('   XOR: ${toBinary(cipher)}');
    print(' Plain: ${toBinary(plain)}');
  }

  print('----- ChaCha20 -----');
  {
    var text = "Hide me!";
    var key = fromHex(
        "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f");
    var nonce = fromHex("000000000000004a00000000");
    var cipher = chacha20(utf8.encode(text), key, nonce);
    var plain = chacha20(cipher, key, nonce);
    print('  Text: $text');
    print('   Key: ${toHex(key)}');
    print(' Nonce: ${toHex(nonce)}');
    print('Cipher: ${toHex(cipher)}');
    print(' Plain: ${utf8.decode(plain)}');
  }
}

Benchmarks #

Libraries:

With 5MB message (10 iterations):

Algorithms cipherlib
XOR 243.84MB/s
XOR(pipe) 66.57TB/s
ChaCha20 125.40MB/s
ChaCha20(pipe) 58.43TB/s

With 1KB message (5000 iterations):

Algorithms cipherlib
XOR 266.28MB/s
XOR(pipe) 13.71GB/s
ChaCha20 129.03MB/s
ChaCha20(pipe) 11.86GB/s

With 10B message (100000 iterations):

Algorithms cipherlib
XOR 190.05MB/s
XOR(pipe) 136.98MB/s
ChaCha20 31.78MB/s
ChaCha20(pipe) 118.66MB/s

All benchmarks are done on AMD Ryzen 7 5800X processor and 3200MHz RAM using compiled exe

Dart SDK version: 3.3.3 (stable) (Tue Mar 26 14:21:33 2024 +0000) on "windows_x64"

4
likes
0
points
60
downloads

Publisher

unverified uploader

Weekly Downloads

Implementations of cryptographic algorithms for encryption and decryption in Dart.

Repository (GitHub)
View/report issues

Funding

Consider supporting this project:

paypal.me

License

unknown (license)

Dependencies

hashlib, hashlib_codecs

More

Packages that depend on cipherlib