From a9c72d27ceff5e6b6333706d1bc711e66cd60b66 Mon Sep 17 00:00:00 2001 From: Hugo Pointcheval Date: Wed, 15 Apr 2020 14:51:16 +0200 Subject: [PATCH] Add some tests --- example/lib/main.dart | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 3858129..90bba15 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -65,22 +65,25 @@ class _MyAppState extends State { var bigFile = Uint8List(megabytes * 1000000); var before = DateTime.now(); - var encrypted = await NativeCrypto().symEncrypt(bigFile, aeskey); + var encryptedBigFile = await NativeCrypto().symEncrypt(bigFile, aeskey); var after = DateTime.now(); var benchmark = after.millisecondsSinceEpoch - before.millisecondsSinceEpoch; output = '$megabytes MB\n\nAES Encryption:\n$benchmark ms\n\n'; - before = DateTime.now(); - var decrypted = await NativeCrypto().symDecrypt(encrypted, aeskey); - after = DateTime.now(); + var beforeDec = DateTime.now(); + var decryptedBigFile = await NativeCrypto().symDecrypt(encryptedBigFile, aeskey); + var afterDec = DateTime.now(); - print(listEquals(bigFile, decrypted)); + print(bigFile.length); + print(decryptedBigFile.length); - benchmark = after.millisecondsSinceEpoch - before.millisecondsSinceEpoch; + print(listEquals(bigFile, decryptedBigFile)); - output += 'AES Decryption:\n$benchmark ms'; + var benchmarkDec = afterDec.millisecondsSinceEpoch - beforeDec.millisecondsSinceEpoch; + + output += 'AES Decryption:\n$benchmarkDec ms'; setState(() { _output = output; @@ -160,10 +163,10 @@ class _MyAppState extends State { style: TextStyle(color: Colors.white), )), FlatButton( - onPressed: () {benchmark(20);}, + onPressed: () {benchmark(50);}, color: Colors.blue, child: Text( - 'Benchmark 20 MB', + 'Benchmark 50 MB', style: TextStyle(color: Colors.white), )), ],