Change some outputs

This commit is contained in:
Hugo Pointcheval 2021-02-16 21:42:06 +01:00
parent 5da95a0c39
commit d6f398af40
3 changed files with 10 additions and 11 deletions

View File

@ -1,5 +1,7 @@
// Copyright (c) 2020 // Copyright (c) 2020
// Author: Hugo Pointcheval // Author: Hugo Pointcheval
import 'dart:developer';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class Output extends StatelessWidget { class Output extends StatelessWidget {
@ -15,14 +17,17 @@ class Output extends StatelessWidget {
final bool editable; final bool editable;
void print(String message) { void print(String message) {
log(message, name: "NativeCrypto Example");
textEditingController.text = message; textEditingController.text = message;
} }
void append(String message) { void append(String message) {
log(message, name: "NativeCrypto Example");
textEditingController.text += message; textEditingController.text += message;
} }
void appendln(String message) { void appendln(String message) {
log(message, name: "NativeCrypto Example");
textEditingController.text += message + "\n"; textEditingController.text += message + "\n";
} }
@ -41,7 +46,7 @@ class Output extends StatelessWidget {
enableInteractiveSelection: true, enableInteractiveSelection: true,
readOnly: editable ? false : true, readOnly: editable ? false : true,
minLines: large ? 3 : 1, minLines: large ? 3 : 1,
maxLines: large ? 50 : 5, maxLines: large ? 500 : 5,
decoration: InputDecoration(border: OutlineInputBorder()), decoration: InputDecoration(border: OutlineInputBorder()),
controller: textEditingController, controller: textEditingController,
), ),

View File

@ -1,4 +1,4 @@
// Copyright (c) 2020 // Copyright (c) 2021
// Author: Hugo Pointcheval // Author: Hugo Pointcheval
export './src/exceptions.dart'; export './src/exceptions.dart';
export './src/key.dart'; export './src/key.dart';
@ -13,6 +13,7 @@ export './src/utils.dart';
export './src/sym/AES.dart'; export './src/sym/AES.dart';
//export './src/asym/RSA.dart'; //export './src/asym/RSA.dart';
const String version = "0.0.5"; const String version = "0.0.6";
const String author = "Hugo Pointcheval"; const String author = "Hugo Pointcheval";
const String website = "https://hugo.pointcheval.fr/"; const String website = "https://hugo.pointcheval.fr/";
const String repository = "https://github.com/hugo-pcl/native-crypto-flutter";

View File

@ -1,7 +1,6 @@
// Copyright (c) 2020 // Copyright (c) 2021
// Author: Hugo Pointcheval // Author: Hugo Pointcheval
import 'dart:developer';
import 'dart:typed_data'; import 'dart:typed_data';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@ -60,11 +59,8 @@ class SecretKey extends Key {
try { try {
Uint8List _key = await Platform().keygen(size); Uint8List _key = await Platform().keygen(size);
log("Generated SecretKey size: ${_key.length * 8} bits (${_key.length} bytes)",
name: "NativeCrypto");
return SecretKey.fromBytes(_key, algorithm: algorithm); return SecretKey.fromBytes(_key, algorithm: algorithm);
} on PlatformException catch (e) { } on PlatformException catch (e) {
log(e.message, name: "NativeCrypto");
throw KeyException(e); throw KeyException(e);
} }
} }
@ -109,10 +105,7 @@ class KeyPair extends Key {
_publicKey = PublicKey.fromBytes(kp.first); _publicKey = PublicKey.fromBytes(kp.first);
_privateKey = PrivateKey.fromBytes(kp.last); _privateKey = PrivateKey.fromBytes(kp.last);
_algo = "RSA"; _algo = "RSA";
log("Generated public and private keys size: ${_publicKey.encoded.length * 8} bits (${_publicKey.encoded.length} bytes)",
name: "NativeCrypto");
} on PlatformException catch (e) { } on PlatformException catch (e) {
log(e.message, name: "NativeCrypto");
throw KeyException(e); throw KeyException(e);
} }
} else { } else {