3617 3615脚本
- # -*-codeing = utf-8 -*-
- # @Time:2023/2/28 11:11
- # @Author:10660
- # @Site:
- # @File:DS3615xs与DS3617xs通用算号.py
- # @Software:PyCharm
- string = "1870ODNxxxx00"
- string_mac = "001132xxxxxx"
- string_new = string
- if string_new[2] == "A":
- string_new = string_new.replace("A", "0")
- elif string_new[2] == "B":
- string_new = string_new.replace("B", "1")
- elif string_new[2] == "C":
- string_new = string_new.replace("C", "2")
- f_out = open('num.txt','r+')
- a=f_out.read()
- a=int(a)+1 #设置算号间隔
- f_out.seek(0) #清除内容
- f_out.truncate()
- f_out.write(str(a))
- f_out.close()
- k = a
- R = 0
- z = string[0:7]
- B = (string[11:13])
- A = int(string[7:10])
- CC = int(string[0:2])
- Y = int(string_new[2])
- AAA = A + k
- BB = str(int(B) + R)
- result = (((1000 * int(BB) + int(AAA)) % CC) + Y) % 10
- x = str(int(k) + A) # 计算x的值,并将其转换为字符串类型
- if len(x) == 3: # 如果x的长度为3,则直接输出x
- full_string = x
- elif len(x) == 2: # 如果x的长度为2,则在x前面添加一个0占位
- full_string = "0" + x
- else: # 否则,在x前面添加两个0占位
- full_string = "00" + x
- if len(BB) ==2:
- full_stringa = BB
- else:
- full_stringa = "0" + BB
- SN = z + full_string + str(result) + full_stringa
- dec_num = int(string_mac[6:12], 16)
- f = (dec_num - int(A) * 4)
- mac = (((1000 * 0 ) + int(AAA) * 4) + f)
- hex_str = hex(mac)[2:].upper()
- new_mac = string_mac[0:6] + hex_str
- mac2 = (((1000 * 0 ) + int(AAA) * 4) + f + 1)
- hex_str_2 = hex(mac2)[2:].upper()
- new_mac2 = string_mac[0:6] + hex_str_2
- mac3 = (((1000 * 0 ) + int(AAA) * 4) + f + 2)
- hex_str_3 = hex(mac3)[2:].upper()
- new_mac3 = string_mac[0:6] + hex_str_3
- mac4 = (((1000 * 0 ) + int(AAA) * 4) + f + 3)
- hex_str_4 = hex(mac4)[2:].upper()
- new_mac4 = string_mac[0:6] + hex_str_4
- print("当前生成的SN:",SN)
- print("当前生成的MAC1:",new_mac)
- print("当前生成的MAC2:",new_mac2)
- print("当前生成的MAC3:",new_mac3)
- print("当前生成的MAC4:",new_mac4)
复制代码
918算号脚本
- # -*-codeing = utf-8 -*-
- # @Time:2023/2/27 14:33
- # @Author:10660
- # @Site:
- # @File:DS918_new.py
- # @Software:PyCharm
- string = "1980PDNxxxx06"
- string_mac = "001132xxxxxx"
- string_new = string
- if string_new[2] == "A":
- string_new = string_new.replace("A", "0")
- elif string_new[2] == "B":
- string_new = string_new.replace("B", "1")
- elif string_new[2] == "C":
- string_new = string_new.replace("C", "2")
- f_out = open('num.txt','r+')
- a=f_out.read()
- a=int(a)+1 #设置算号间隔
- f_out.seek(0) #清除内容
- f_out.truncate()
- f_out.write(str(a))
- f_out.close()
- k = a
- R = 0
- z = string[0:7]
- B = (string[11:13])
- A = int(string[7:10])
- CC = int(string[0:2])
- Y = int(string_new[2])
- AAA = A + k
- BB = str(int(B) + R)
- result = (((1000 * int(BB) + int(AAA)) % CC) + Y) % 10
- x = str(int(k) + A) # 计算x的值,并将其转换为字符串类型
- if len(x) == 3: # 如果x的长度为3,则直接输出x
- full_string = x
- elif len(x) == 2: # 如果x的长度为2,则在x前面添加一个0占位
- full_string = "0" + x
- else: # 否则,在x前面添加两个0占位
- full_string = "00" + x
- if len(BB) ==2:
- full_stringa = BB
- else:
- full_stringa = "0" + BB
- SN = z + full_string + str(result) + full_stringa
- dec_num = int(string_mac[6:12], 16)
- f = (dec_num - int(A) * 2)
- mac = (((1000 * 0 ) + int(AAA) * 2) + f)
- hex_str = hex(mac)[2:].upper()
- new_mac = string_mac[0:6] + hex_str
- mac2 = (((1000 * 0 ) + int(AAA) * 2) + f + 1)
- hex_str_2 = hex(mac2)[2:].upper()
- new_mac2 = string_mac[0:6] + hex_str_2
- print("当前生成的SN:",SN)
- print("当前生成的MAC1:",new_mac)
- print("当前生成的MAC2:",new_mac2)
复制代码
需要在脚本相同文件夹下面创建一个num.txt文件并且将值设置为0,每次运行之前都需要将值置于0的状态
|
|