From e58132124d17e49926dedb6dd126ec02bf9f73b4 Mon Sep 17 00:00:00 2001 From: Hugo Pointcheval Date: Wed, 15 Apr 2020 21:34:36 +0200 Subject: [PATCH] Fix and clean native_crypto api --- lib/{ => src}/native_crypto.dart | 15 ++++++++++----- test/native_crypto_test.dart | 1 - 2 files changed, 10 insertions(+), 6 deletions(-) rename lib/{ => src}/native_crypto.dart (81%) diff --git a/lib/native_crypto.dart b/lib/src/native_crypto.dart similarity index 81% rename from lib/native_crypto.dart rename to lib/src/native_crypto.dart index 9fe6c44..23b1bf8 100644 --- a/lib/native_crypto.dart +++ b/lib/src/native_crypto.dart @@ -5,20 +5,25 @@ import 'dart:typed_data'; import 'package:flutter/services.dart'; +/// [Sources] /// Plugin class. /// Contains raw functions. /// -/// You can use [symmetrical_crypto] for an **AES Helper**. +/// Use [symmetrical_crypto] for an **AES API**. class NativeCrypto { + /// [Private] + /// Contains the channel for platform specific code. static const MethodChannel _channel = const MethodChannel('native.crypto.helper'); /// Generates AES key. /// - /// Size of **256 bits** by design. - /// And returns `Uint8List`. - Future symKeygen() async { - final Uint8List aesKey = await _channel.invokeMethod('symKeygen'); + /// [size] is in bits, 128, 192 or 256. + /// It returns an `Uint8List`. + Future symKeygen(int size) async { + final Uint8List aesKey = await _channel.invokeMethod('symKeygen', { + 'size': size + }); return aesKey; } diff --git a/test/native_crypto_test.dart b/test/native_crypto_test.dart index 92f6030..1787622 100644 --- a/test/native_crypto_test.dart +++ b/test/native_crypto_test.dart @@ -1,6 +1,5 @@ import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:native_crypto/native_crypto.dart'; void main() { const MethodChannel channel = MethodChannel('native_crypto');