Add logs in api
This commit is contained in:
parent
a13ded08a4
commit
da99b70ee6
@ -1,29 +1,40 @@
|
|||||||
// Copyright (c) 2020
|
// Copyright (c) 2020
|
||||||
// Author: Hugo Pointcheval
|
// Author: Hugo Pointcheval
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'dart:developer';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
class NativeCrypto {
|
class NativeCrypto {
|
||||||
|
static const String _tag = 'fr.pointcheval.native_crypto';
|
||||||
static const MethodChannel _channel =
|
static const MethodChannel _channel =
|
||||||
const MethodChannel('native.crypto.helper');
|
const MethodChannel('native.crypto.helper');
|
||||||
|
|
||||||
Future<Uint8List> sumKeygen() async {
|
Future<Uint8List> sumKeygen() async {
|
||||||
final Uint8List aesKey = await _channel.invokeMethod('symKeygen');
|
final Uint8List aesKey = await _channel.invokeMethod('symKeygen');
|
||||||
|
|
||||||
|
log('AES Key Length: ${aesKey.length}', name: _tag);
|
||||||
|
print('AES Key: $aesKey');
|
||||||
|
|
||||||
return aesKey;
|
return aesKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<Uint8List>> symEncrypt(
|
Future<List<Uint8List>> symEncrypt(
|
||||||
Uint8List payloadbytes, Uint8List aesKey) async {
|
Uint8List payloadbytes, Uint8List aesKey) async {
|
||||||
final List<Uint8List> encyptedPayload =
|
final List<Uint8List> encryptedPayload =
|
||||||
await _channel.invokeListMethod('symEncrypt', <String, dynamic>{
|
await _channel.invokeListMethod('symEncrypt', <String, dynamic>{
|
||||||
'payload': payloadbytes,
|
'payload': payloadbytes,
|
||||||
'aesKey': aesKey,
|
'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<Uint8List> symDecrypt(
|
Future<Uint8List> symDecrypt(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user