mirror of
https://github.com/hackku21/loc-chain-app.git
synced 2024-10-27 20:34:05 +00:00
start hash work
This commit is contained in:
parent
69def3c28b
commit
7ceaa12c8d
@ -1,54 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import 'package:fast_rsa/rsa.dart';
|
||||
import 'package:fast_rsa/model/bridge.pb.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
class KeyFileManager {
|
||||
static Future<String> get _localPath async {
|
||||
final directory = await getApplicationDocumentsDirectory();
|
||||
return directory.path;
|
||||
}
|
||||
|
||||
static Future<File> get _pubKeyFile async {
|
||||
final path = await _localPath;
|
||||
return File('$path/rsa.pub');
|
||||
}
|
||||
|
||||
static Future<File> get _privKeyFile async {
|
||||
final path = await _localPath;
|
||||
return File('$path/rsa');
|
||||
}
|
||||
|
||||
static Future<KeyPair> readKeyPair() async {
|
||||
try {
|
||||
String privKey = await _privKeyFile.then(
|
||||
(file) => file.readAsString(),
|
||||
);
|
||||
String pubKey = await _pubKeyFile.then(
|
||||
(file) => file.readAsString(),
|
||||
);
|
||||
|
||||
return KeyPair(
|
||||
privateKey: privKey,
|
||||
publicKey: pubKey,
|
||||
);
|
||||
} catch (e) {
|
||||
print(e);
|
||||
return KeyPair();
|
||||
}
|
||||
}
|
||||
|
||||
static Future<void> writeKeyPair(KeyPair pair) async {
|
||||
final File privKeyFile = await _privKeyFile;
|
||||
final File pubKeyFile = await _pubKeyFile;
|
||||
pubKeyFile.writeAsString(pair.publicKey);
|
||||
privKeyFile.writeAsString(pair.privateKey);
|
||||
}
|
||||
}
|
||||
import 'package:loc_chain_app/util/keyfile_manager.dart';
|
||||
|
||||
class KeygenPage extends StatefulWidget {
|
||||
KeygenPage({Key? key, required this.title}) : super(key: key);
|
||||
|
46
loc_chain_app/lib/util/keyfile_manager.dart
Normal file
46
loc_chain_app/lib/util/keyfile_manager.dart
Normal file
@ -0,0 +1,46 @@
|
||||
import 'package:fast_rsa/model/bridge.pb.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'dart:io';
|
||||
|
||||
class KeyFileManager {
|
||||
static Future<String> get _localPath async {
|
||||
final directory = await getApplicationDocumentsDirectory();
|
||||
return directory.path;
|
||||
}
|
||||
|
||||
static Future<File> get _pubKeyFile async {
|
||||
final path = await _localPath;
|
||||
return File('$path/rsa.pub');
|
||||
}
|
||||
|
||||
static Future<File> get _privKeyFile async {
|
||||
final path = await _localPath;
|
||||
return File('$path/rsa');
|
||||
}
|
||||
|
||||
static Future<KeyPair> readKeyPair() async {
|
||||
try {
|
||||
String privKey = await _privKeyFile.then(
|
||||
(file) => file.readAsString(),
|
||||
);
|
||||
String pubKey = await _pubKeyFile.then(
|
||||
(file) => file.readAsString(),
|
||||
);
|
||||
|
||||
return KeyPair(
|
||||
privateKey: privKey,
|
||||
publicKey: pubKey,
|
||||
);
|
||||
} catch (e) {
|
||||
print(e);
|
||||
return KeyPair();
|
||||
}
|
||||
}
|
||||
|
||||
static Future<void> writeKeyPair(KeyPair pair) async {
|
||||
final File privKeyFile = await _privKeyFile;
|
||||
final File pubKeyFile = await _pubKeyFile;
|
||||
pubKeyFile.writeAsString(pair.publicKey);
|
||||
privKeyFile.writeAsString(pair.privateKey);
|
||||
}
|
||||
}
|
5
loc_chain_app/lib/util/transaction.dart
Normal file
5
loc_chain_app/lib/util/transaction.dart
Normal file
@ -0,0 +1,5 @@
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:fast_rsa/model/bridge.pb.dart';
|
||||
import 'package:fast_rsa/rsa.dart';
|
||||
|
||||
class Transaction {}
|
Loading…
Reference in New Issue
Block a user