app-starlock/star_lock/lib/blue/io_protocol/io_getPrivateKey.dart

75 lines
1.8 KiB
Dart
Raw Normal View History

2023-08-09 09:32:09 +08:00
import 'dart:convert';
2023-08-09 15:42:26 +08:00
import '../io_tool/io_tool.dart';
2023-08-09 09:32:09 +08:00
import 'io_reply.dart';
import 'io_sender.dart';
import 'io_type.dart';
class GetPrivateKeyCommand extends SenderProtocol {
String? lockID;
2023-08-09 15:42:26 +08:00
String? keyID; // 钥匙ID
String? authUserID; // 钥匙授权人ID
int? nowTime;
String? authCode;
int? needAuthor;
2023-08-09 09:32:09 +08:00
GetPrivateKeyCommand({
this.lockID,
2023-08-09 15:42:26 +08:00
this.keyID,
this.authUserID,
this.nowTime,
this.authCode,
}) : super(CommandType.getLockPrivateKey);
2023-08-09 09:32:09 +08:00
@override
List<int> messageDetail() {
List<int> data = [];
print("lockID${lockID!} lockID.utf8.encode${utf8.encode(lockID!)}");
2023-08-09 15:42:26 +08:00
// 锁id
int lockIDLength = utf8.encode(lockID!).length;
2023-08-09 09:32:09 +08:00
data.addAll(utf8.encode(lockID!));
2023-08-09 15:42:26 +08:00
data = getFixedLengthList(data, 40 - lockIDLength);
//KeyID 40
int keyIDLength = utf8.encode(keyID!).length;
data.addAll(utf8.encode(keyID!));
data = getFixedLengthList(data, 40 - keyIDLength);
//authUserID 40
int authUserIDLength = utf8.encode(authUserID!).length;
data.addAll(utf8.encode(authUserID!));
data = getFixedLengthList(data, 20 - authUserIDLength);
//NowTime 4
DateTime now = DateTime.now();
int timestamp = now.millisecondsSinceEpoch;
data.add((timestamp & 0xff000000) >> 24);
data.add((timestamp & 0xff0000) >> 16);
data.add((timestamp & 0xff00) >> 8);
data.add((timestamp & 0xff));
if(needAuthor == 0){
2023-08-09 09:32:09 +08:00
data.add(0);
2023-08-09 15:42:26 +08:00
}else{
2023-08-09 09:32:09 +08:00
}
return data;
}
}
class GetPrivateKeyReply extends Reply {
GetPrivateKeyReply.parseData(CommandType commandType, List<int> dataDetail)
: super.parseData(commandType, dataDetail) {
print('获取私钥');
int index = 0;
// while(index < endIndex){
// commandKey = byteUInt8(dataDetail, index);
// index += offset_1;
// switch(commandKey){
//
// }
// }
}
}