app-starlock/lib/blue/io_protocol/io_automaticPadlock.dart
2024-05-18 09:37:50 +08:00

79 lines
2.2 KiB
Dart
Executable File
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 '../sm4Encipher/sm4.dart';
import '../io_reply.dart';
import '../io_sender.dart';
import '../io_type.dart';
import 'package:crypto/crypto.dart' as crypto;
//TODO:自动落锁开关
/// 废弃
// class AutomaticPadlockCommand extends SenderProtocol {
// String? lockID;
// String? userID;
// int? autoLockFlag;
// List<int>? token;
// int? needAuthor;
// List<int>? signKey;
// List<int>? privateKey;
// AutomaticPadlockCommand({
// this.lockID,
// this.userID,
// this.autoLockFlag,
// this.token,
// this.needAuthor,
// this.signKey,
// this.privateKey
// }) : super(CommandType.generalExtendedCommond);
//
// @override
// List<int> messageDetail() {
// List<int> data = [];
// List<int> subData = [];
// List<int> ebcData = [];
//
// // 指令类型
// int type = commandType!.typeValue;
// double typeDouble = type / 256;
// int type1 = typeDouble.toInt();
// int type2 = type % 256;
// data.add(type1);
// data.add(type2);
//
// // 子命令类型
// data.add(4);
//
// //lockID 40
// int lockIDLength = utf8.encode(lockID!).length;
// subData.addAll(utf8.encode(lockID!));
// subData = getFixedLengthList(subData, 40 - lockIDLength);
//
// //userID 要接受钥匙的用户的useid 20
// int userIDLength = utf8.encode(userID!).length;
// subData.addAll(utf8.encode(userID!));
// subData = getFixedLengthList(subData, 20 - userIDLength);
//
// // autoLockFlag 0不自动落锁1自动落锁
// subData.add(autoLockFlag!);
//
// data.add(subData.length);
// data.addAll(subData);
//
// if ((data.length % 16) != 0) {
// int add = (16 - data.length % 16);
// for (int i = 0; i < add; i++) {
// data.add(0);
// }
// }
// ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
// return ebcData;
// }
// }
//
// class AutomaticPadlockReply extends Reply {
// AutomaticPadlockReply.parseData(CommandType commandType, List<int> dataDetail)
// : super.parseData(commandType, dataDetail) {
// data = dataDetail;
// }
// }