调试公钥本地储存

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

View File

@ -50,7 +50,11 @@ class GetPublicKeyReply extends Reply {
String stringEncoded = base64.encode(tokenData);
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);
break;
case 0x07:

View File

@ -5,6 +5,19 @@ import 'package:shared_preferences/shared_preferences.dart';
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 {
// SharedPreferences sp = await SharedPreferences.getInstance();