mirror of
https://github.com/hackku21/loc-chain-app.git
synced 2024-10-27 20:34:05 +00:00
implemented hashing
This commit is contained in:
parent
8e2a30647b
commit
a7c7133d4f
@ -3,15 +3,25 @@ import 'package:shared_preferences/shared_preferences.dart';
|
|||||||
import 'package:sqflite/sqflite.dart';
|
import 'package:sqflite/sqflite.dart';
|
||||||
import 'package:fast_rsa/rsa.dart';
|
import 'package:fast_rsa/rsa.dart';
|
||||||
|
|
||||||
|
import 'package:loc_chain_app/util/keyfile_manager.dart';
|
||||||
|
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
class Transaction {
|
class Transaction {
|
||||||
Transaction({required this.otherUserID}) {
|
Transaction({required this.hash}) {
|
||||||
SharedPreferences.getInstance().then((s) => _id = s.getString('id') ?? '0');
|
SharedPreferences.getInstance().then((s) => _id = s.getString('id') ?? '0');
|
||||||
}
|
}
|
||||||
late final String _id;
|
late final String _id;
|
||||||
final String otherUserID;
|
final String hash;
|
||||||
static Hash? makeTransactionHash() {}
|
static Future<String> makeTransactionHash(String otherUserId) async {
|
||||||
|
String id = await SharedPreferences.getInstance()
|
||||||
|
.then((s) => s.getString('id') ?? '');
|
||||||
|
bool idLess = id.compareTo(otherUserId) < 0;
|
||||||
|
var lesser = idLess ? id : otherUserId;
|
||||||
|
var greater = idLess ? otherUserId : id;
|
||||||
|
return RSA.signPKCS1v15("$lesser-$greater", Hash.HASH_SHA256,
|
||||||
|
KeyFileManager.keyPair.privateKey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TransactionsDBManager {
|
class TransactionsDBManager {
|
||||||
|
Loading…
Reference in New Issue
Block a user