【进度】啊啊啊啊冲

1106

1.完善了一下专利,基本逻辑无误

2.下午讨论捋顺了整个流程关系

2.把指纹完整生成的代码复现了

#输入:设备类型,状态,采集数据
#输出:哈希


import hashlib
import binascii
# 导入国密算法sm4包
from gmssl import sm4, sm3
def sm3_hash(message):
    """
    国密sm3加密
    :param message: 消息值,bytes类型
    :return: 哈希值
    """
    msg_list = [i for i in message]
    hash_hex = sm3.sm3_hash(msg_list)
    #print(hash_hex)
    return hash_hex

# 基本信息
input_string1 = "H3C S3100V2-26TP-SIH3C S3100V2-26TP-SI00210235A0K7C126002633".encode()
# 操作系统
input_string2 = "LinuxGNU/Linux4.14.155Welcome to Shuniu2.0 OS".encode()
# 芯片
input_string3 = "0Cortex-A7".encode()
# 通信
input_string4 = "IPSNMP111000000222380192.168.1.100".encode()

type = input("请输入设备类型(如0006为智能终端): ")
status = input("请输入设备状态(0停用1运行2故障3测试): ")


########设备类型:采集的时候选定设备类型,选大类+小类#########
# 0 电力工控终端
# 1 物联终端
# 2 办公终端
#-------------
# 001 DTU
# 002 PMU
# 003 配电终端
# 004 互感器
# 005 集中器
# 006 智能终端
# 1.数据从平台获取,用户选择采集信息的时候选择
# 2.对应设备确定好固定的策略,比如交换机固定1001,智能终端固定1111
if type == '0001':
    strategy = "0001"
elif type == '0006':
    # 智能终端
    strategy = "1111"
elif type == '1003':
    # 交换机
    strategy = "1001"
elif type == '2001':
    # PC
    strategy = "1111"
else:
    print("Error!")
######################################################

#######################设备状态#########################
# 0 停用
# 1 运行
# 2 故障检修
# 3 测试/实验
######################################################


if strategy == "1111":
    thash = sm3_hash(input_string1)[-10:]+sm3_hash(input_string2)[-10:]+sm3_hash(input_string3)[-10:]+sm3_hash(input_string4)[-10:]
elif strategy == "1011":
    thash = sm3_hash(input_string1)[-16:] + sm3_hash(input_string3)[-12:] + sm3_hash(input_string4)[-12:]
elif strategy == "1101":
    thash = sm3_hash(input_string1)[-16:] + sm3_hash(input_string2)[-12:] + sm3_hash(input_string4)[-12:]
elif strategy == "1110":
    thash = sm3_hash(input_string1)[-16:] + sm3_hash(input_string2)[-12:] + sm3_hash(input_string3)[-12:]
elif strategy == "1001":
    thash = sm3_hash(input_string1)[-20:] + sm3_hash(input_string4)[-20:]
elif strategy == "1010":
    thash = sm3_hash(input_string1)[-20:] + sm3_hash(input_string3)[-20:]
elif strategy == "1100":
    thash = sm3_hash(input_string1)[-20:] + sm3_hash(input_string2)[-20:]
elif strategy == "1000":
    thash = sm3_hash(input_string1)[-40:]
else:
    print("Error!")

def calculate_hex_checksum(data):
    checksum = 0
    for char in data:
        checksum += ord(char)
    checksum_hex = format(checksum % 256, '02X')  # Ensure it's a two-digit hex value
    return checksum_hex

# 前缀码 + 类型 +状态 + 特征哈希
result = "cnsma"+ type+ status +thash
hex_checksum = calculate_hex_checksum(result)
result = result + hex_checksum
print("特征哈希:", result)

#########验证##########
# def verify_checksum(input_string):
#     data = input_string[:-2]  # Remove the last two characters (the checksum)
#     provided_checksum = input_string[-2:]  # Get the last two characters as the provided checksum
#     calculated_checksum = calculate_hex_checksum(data)  # Recalculate the checksum
#
#     if provided_checksum == calculated_checksum:
#         return True  # Checksum is valid
#     else:
#         return False  # Checksum is invalid
#
# input_string = "cnsma000608d8a1b7a45d7616091f9262e440dceD2"
# if verify_checksum(input_string):
#     print("Checksum is valid.")
# else:
#     print("Checksum is invalid.")

1107

写概要说明书和详细说明书,画了2.3个框架图,给学弟分配任务

1108

写了一天的文档,画了mqtt的订阅发布图, 研究它的包

1109

一天的文档,整理文档

1113

写http接口

1114

一天课,晚上总结了一下详细说明书发过去

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值