app-starlock/star_lock/lib/blue/io_protocol/io_getPrivateKey.dart
2023-08-09 15:42:26 +08:00

75 lines
1.8 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'dart:convert';
import '../io_tool/io_tool.dart';
import 'io_reply.dart';
import 'io_sender.dart';
import 'io_type.dart';
class GetPrivateKeyCommand extends SenderProtocol {
String? lockID;
String? keyID; // 钥匙ID
String? authUserID; // 钥匙授权人ID
int? nowTime;
String? authCode;
int? needAuthor;
GetPrivateKeyCommand({
this.lockID,
this.keyID,
this.authUserID,
this.nowTime,
this.authCode,
}) : super(CommandType.getLockPrivateKey);
@override
List<int> messageDetail() {
List<int> data = [];
print("lockID${lockID!} lockID.utf8.encode${utf8.encode(lockID!)}");
// 锁id
int lockIDLength = utf8.encode(lockID!).length;
data.addAll(utf8.encode(lockID!));
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){
data.add(0);
}else{
}
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){
//
// }
// }
}
}