调试公钥本地储存

This commit is contained in:
魏少阳 2023-08-14 14:20:35 +08:00
parent dfc5dc433f
commit d91f59db48
3 changed files with 30 additions and 9 deletions

View File

@ -2,6 +2,7 @@ import 'dart:convert';
import 'package:star_lock/blue/sm4Encipher/sm4.dart'; import 'package:star_lock/blue/sm4Encipher/sm4.dart';
import '../../tools/storage.dart';
import '../io_tool/io_tool.dart'; import '../io_tool/io_tool.dart';
import 'io_reply.dart'; import 'io_reply.dart';
import 'io_sender.dart'; import 'io_sender.dart';
@ -86,14 +87,17 @@ class GetPrivateKeyCommand extends SenderProtocol {
authCodeData.add((d1 & 0xff00) >> 8); authCodeData.add((d1 & 0xff00) >> 8);
authCodeData.add((d1 & 0xff)); authCodeData.add((d1 & 0xff));
// String pubKey = ""; List<int> getIntList;
// Storage.getData("bluePublicKey").then((res) => { Storage.getStringList("bluePublicKey").then((res) {
// pubKey = res print("getStrList:$res");
// }); getIntList = changeStringListToIntList(res!);
// var pubKey = "ovOvAHuL5+dBCw7L3Qt7IQ=="; print("getIntList:$getIntList");
// print("pubKey:$pubKey"); });
// List<int> pubKeyData = base64.decode(pubKey.toString());
// print("pubKeyData:$pubKeyData"); // List<String> getStrList = Storage.getLocalStorage("bluePublicKey") as List<String>;
// List<int> getIntList = changeStringListToIntList(getStrList);
// print("getIntList:$getIntList");
authCodeData.addAll(publicKeyData!); authCodeData.addAll(publicKeyData!);
// KeyIDauthUserIDmd5加密之后就是authCode // KeyIDauthUserIDmd5加密之后就是authCode

View File

@ -50,7 +50,11 @@ class GetPublicKeyReply extends Reply {
String stringEncoded = base64.encode(tokenData); String stringEncoded = base64.encode(tokenData);
print('获取公钥成功 publickey:$stringEncoded'); print('获取公钥成功 publickey:$stringEncoded');
// //
// Storage.setData("bluePublicKey", stringEncoded); var saveStrList = changeIntListToStringList(tokenData);
// Storage.setStringList("bluePublicKey", saveStrList);
Storage.setStringList("bluePublicKey", saveStrList);
// List<String> getStrList = Storage.getLocalStorage("bluePublicKey") as List<String>;
// print('获取储存的公钥 getStrList:$getStrList');
IoSenderManage.getPrivateKey("TMH_c3570480da8d", "1", "1", 1, tokenData, 1); IoSenderManage.getPrivateKey("TMH_c3570480da8d", "1", "1", 1, tokenData, 1);
break; break;
case 0x07: case 0x07:

View File

@ -5,6 +5,19 @@ import 'package:shared_preferences/shared_preferences.dart';
class Storage{ class Storage{
// Storage._internal();
//
// factory Storage() => _instance;
//
// static late final Storage _instance = Storage._internal();
//
// static late SharedPreferences _preferences;
//
// static Future<Storage> getInstance() async {
// _preferences = await SharedPreferences.getInstance();
// return _instance;
// }
// /// // ///
// static Future<void> setData(key, value) async { // static Future<void> setData(key, value) async {
// SharedPreferences sp = await SharedPreferences.getInstance(); // SharedPreferences sp = await SharedPreferences.getInstance();