diff --git a/lib/native_crypto.dart b/lib/native_crypto.dart index d515a4a..a487bec 100644 --- a/lib/native_crypto.dart +++ b/lib/native_crypto.dart @@ -1,29 +1,40 @@ // Copyright (c) 2020 // Author: Hugo Pointcheval import 'dart:async'; +import 'dart:developer'; import 'dart:typed_data'; import 'package:flutter/services.dart'; class NativeCrypto { + static const String _tag = 'fr.pointcheval.native_crypto'; static const MethodChannel _channel = const MethodChannel('native.crypto.helper'); Future sumKeygen() async { final Uint8List aesKey = await _channel.invokeMethod('symKeygen'); + log('AES Key Length: ${aesKey.length}', name: _tag); + print('AES Key: $aesKey'); + return aesKey; } Future> symEncrypt( Uint8List payloadbytes, Uint8List aesKey) async { - final List encyptedPayload = + final List encryptedPayload = await _channel.invokeListMethod('symEncrypt', { 'payload': payloadbytes, 'aesKey': aesKey, }); - return encyptedPayload; + log('Payload Length: ${payloadbytes.length}', name: _tag); + log('Cipher Length: ${encryptedPayload.first.length}', name: _tag); + print('Cipher: ${encryptedPayload.first}'); + log('IV Length: ${encryptedPayload.last.length}', name: _tag); + print('IV: ${encryptedPayload.last}'); + + return encryptedPayload; } Future symDecrypt(