Files
2026-06-21 17:13:18 +08:00

638 lines
33 KiB
Python
Raw Permalink 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.
# -- coding: utf-8 --
import platform
from datetime import datetime
import random
from ctypes import *
if 'Windows' in platform.system():
if "32bit" in platform.architecture():
Psyuunew=windll.LoadLibrary('Syunew3D.dll')
else:
Psyuunew=windll.LoadLibrary('Syunew3D_x64.dll')
else:
if "32bit" in platform.architecture():
Psyuunew=windll.LoadLibrary('libPsyunew3.so')
else:
Psyuunew=cdll.LoadLibrary('libPsyunew3_arm8.so')
##�����İ汾
NT_GetIDVersion=Psyuunew.NT_GetIDVersion
NT_GetIDVersion.argtypes=(c_void_p,c_char_p)
NT_GetIDVersion.restypes=(c_int)
##��ȡ������չ�汾
NT_GetVersionEx=Psyuunew.NT_GetVersionEx
NT_GetVersionEx.argtypes=(c_void_p,c_char_p)
NT_GetVersionEx.restypes=(c_int)
##�㷨����
sWrite_2Ex=Psyuunew.sWrite_2Ex
sWrite_2Ex.argtypes=(c_ulong ,c_void_p,c_char_p)
sWrite_2Ex.restypes=(c_int)
sWriteEx=Psyuunew.sWriteEx
sWriteEx.argtypes=(c_ulong ,c_void_p,c_char_p)
sWriteEx.restypes=(c_int)
sRead=Psyuunew.sRead
sRead.argtypes=(c_void_p,c_char_p)
sRead.restypes=(c_int)
sWrite_2=Psyuunew.sWrite
sWrite_2.argtypes=(c_ulong ,c_char_p)
sWrite_2.restypes=(c_int)
sWrite_2=Psyuunew.sWrite_2
Psyuunew.argtypes=(c_ulong ,c_char_p)
sWrite_2.restypes=(c_int)
##�㷨����
##дһ���ֽڵ���������
YWrite=Psyuunew.YWrite
YWrite.argtypes=(c_byte ,c_short,c_char_p ,c_char_p,c_char_p )
YWrite.restypes=(c_int)
##�Ӽ������ж�ȡһ����??
YRead=Psyuunew.YRead
YRead.argtypes=(c_void_p,c_short,c_char_p ,c_char_p,c_char_p )
YRead.restypes=(c_int)
##дһ���ֽڵ���������
YWriteEx=Psyuunew.YWriteEx
YWriteEx.argtypes=(c_void_p,c_short,c_short,c_char_p,c_char_p,c_char_p )
YWriteEx.restypes=(c_int)
##�Ӽ������ж�ȡһ����??
YReadEx=Psyuunew.YReadEx
YReadEx.argtypes=(c_void_p,c_short,c_short,c_char_p,c_char_p,c_char_p )
YReadEx.restypes=(c_int)
##����ָ���ļ�������ʹ����ͨ�㷨һ??
FindPort_2=Psyuunew.FindPort_2
FindPort_2.argtypes=(c_int ,c_ulong ,c_ulong ,c_char_p)
FindPort_2.restypes=(c_int)
##���Ҽ���??
FindPort=Psyuunew.FindPort
FindPort.argtypes=(c_int ,c_char_p)
FindPort.restypes=(c_int)
##��ȡ����ID
GetID=Psyuunew.GetID
GetID.argtypes=(c_void_p,c_void_p,c_char_p)
GetID.restypes=(c_int)
##�Ӽ������ж��ַ�??
YReadString=Psyuunew.YReadString
YReadString.argtypes=(c_char_p ,c_short,c_int ,c_char_p ,c_char_p,c_char_p)
YReadString.restypes=(c_int)
##д�ַ�����������??
YWriteString=Psyuunew.YWriteString
YWriteString.argtypes=(c_char_p,c_short,c_char_p ,c_char_p,c_char_p )
YWriteString.restypes=(c_int)
##�����??
SetWritePassword=Psyuunew.SetWritePassword
SetWritePassword.argtypes=(c_char_p ,c_char_p,c_char_p ,c_char_p,c_char_p)
SetWritePassword.restypes=(c_int)
##���ö���??
SetReadPassword=Psyuunew.SetReadPassword
SetReadPassword.argtypes=(c_char_p ,c_char_p,c_char_p ,c_char_p,c_char_p)
SetReadPassword.restypes=(c_int)
##������ǿ�㷨��Կһ
SetCal_2=Psyuunew.SetCal_2
SetCal_2.argtypes=(c_char_p,c_char_p)
SetCal_2.restypes=(c_int)
##ʹ����ǿ�㷨һ���ַ������м���
EncString=Psyuunew.EncString
EncString.argtypes=(c_char_p,c_char_p,c_char_p)
EncString.restypes=(c_int)
##ʹ����ǿ�㷨һ�Զ��������ݽ��м���
Cal=Psyuunew.Cal
Cal.argtypes=(c_void_p,c_void_p,c_char_p)
Cal.restypes=(c_int)
##������ǿ�㷨��Կ??
SetCal_New=Psyuunew.SetCal_New
SetCal_New.argtypes=(c_char_p,c_char_p)
SetCal_New.restypes=(c_int)
##ʹ����ǿ�㷨�����ַ������м�??
Cal_New=Psyuunew.Cal_New
Cal_New.argtypes=(c_void_p,c_void_p,c_char_p)
Cal_New.restypes=(c_int)
##ʹ����ǿ�㷨�����ַ������м�??
EncString_New=Psyuunew.EncString_New
EncString_New.argtypes=(c_char_p,c_char_p,c_char_p)
EncString_New.restypes=(c_int)
##�������ij�������
GetProduceDate=Psyuunew.GetProduceDate
GetProduceDate.argtypes=(c_char_p,c_char_p)
GetProduceDate.restypes=(c_int)
##����ID����
SetID=Psyuunew.SetID
SetID.argtypes=(c_char_p ,c_char_p)
SetID.restypes=(c_int)
##������ͨ��??
SetCal=Psyuunew.SetCal
SetCal.argtypes=(c_char_p ,c_char_p,c_char_p ,c_char_p,c_char_p)
SetCal.restypes=(c_int)
##��������ת������
##SnToProduceDate=Psyuunew.SnToProduceDate
##SnToProduceDate.argtypes=(c_char_p ,c_char_p )
##SnToProduceDate.restypes=(c_void)
##ʹ����ǿ�㷨���ַ������н���ʹ������
##StrDec=Psyuunew.StrDec
##StrDec.argtypes=(c_char_p,c_char_p,c_char_p)
##StrDec.restypes=(c_void )
##
##StrEnc=Psyuunew.StrEnc
##StrEnc.argtypes=(c_char_p,c_char_p,c_char_p)
##StrEnc.restypes=(c_void)
##
##EnCode=Psyuunew.EnCode
##EnCode.argtypes=(c_void_p ,c_void_p , c_char_p )
##EnCode.restypes=(c_void)
##
##DeCode=Psyuunew.DeCode
##DeCode.argtypes=(c_void_p , c_void_p , c_char_p )
##DeCode.restypes=(c_void)
##ʹ����ǿ�㷨���ַ������н���ʹ������)
##ʹ����ǿ�㷨�Զ��������ݽ��м���ʹ������)
##DecBySoft=Psyuunew.DecBySoft
##DecBySoft.argtypes=(c_void_p, c_void_p )
##EncBySoft=Psyuunew.EncBySoft
##EncBySoft.argtypes=(c_void_p , c_void_p )
##ʹ����ǿ�㷨�Զ��������ݽ��м���ʹ������)
##�ַ��������������ݵ�ת��
##HexStringToc_byteArray=Psyuunew.HexStringToc_byteArray
##HexStringToc_byteArray.argtypes=(c_char_p ,c_void_p)
##HexStringToc_byteArray.restypes=(c_void)
##
##ByteArrayToHexString=Psyuunew.ByteArrayToHexString
##ByteArrayToHexString.argtypes=(c_void_p,c_char_p ,c_int )
##ByteArrayToHexString.restypes=(c_void)
##�ַ��������������ݵ�ת��
##��ʼ��������,ע�⣬��ʼ���������е�����??����д����Ҳ??0000000-00000000����ǿ�㷨���ᱻ��ʼ??
ReSet=Psyuunew.ReSet
ReSet.argtypes=[c_char_p]
ReSet.restypes=(c_int)
##���º���ֻ���ڴ�U�̵�??
##�����Ƿ���ʾU�̲����̷�����Ϊ��ʾ����Ϊ����ʾ
SetHidOnly=Psyuunew.SetHidOnly
SetHidOnly.argtypes=( c_bool,c_char_p)
SetHidOnly.restypes=(c_int)
##����U�̲���Ϊֻ��״̬��
SetUReadOnly=Psyuunew.SetUReadOnly
SetUReadOnly.argtypes=[c_char_p]
SetUReadOnly.restypes=(c_int)
##���Ϻ���ֻ���ڴ�U�̵�??
##���º���ֻ֧������оƬ��??
##����SM2��Կ??
YT_GenKeyPair=Psyuunew.YT_GenKeyPair
YT_GenKeyPair.argtypes=(c_char_p ,c_char_p,c_char_p,c_char_p)
YT_GenKeyPair.restypes=(c_int)
##����Pin??
YtSetPin=Psyuunew.YtSetPin
YtSetPin.argtypes=(c_char_p,c_char_p,c_char_p )
YtSetPin.restypes=(c_int)
##����SM2��Կ�Լ�����
Set_SM2_KeyPair=Psyuunew.Set_SM2_KeyPair
Set_SM2_KeyPair.argtypes=(c_char_p,c_char_p,c_char_p,c_char_p,c_char_p )
Set_SM2_KeyPair.restypes=(c_int)
##���ؼ������Ĺ�Կ
Get_SM2_PubKey=Psyuunew.Get_SM2_PubKey
Get_SM2_PubKey.argtypes=(c_char_p,c_char_p,c_char_p,c_char_p)
Get_SM2_PubKey.restypes=(c_int)
##�Զ��������ݽ���SM2����
SM2_EncBuf=Psyuunew.SM2_EncBuf
SM2_EncBuf.argtypes=(c_void_p,c_void_p,c_int ,c_char_p)
SM2_EncBuf.restypes=(c_int)
##�Զ��������ݽ���SM2����
SM2_DecBuf=Psyuunew.SM2_DecBuf
SM2_DecBuf.argtypes=(c_void_p,c_void_p,c_int ,c_char_p ,c_char_p)
SM2_DecBuf.restypes=(c_int)
##���ַ�������SM2����
SM2_EncString=Psyuunew. SM2_EncString
SM2_EncString.argtypes=(c_char_p,c_char_p,c_char_p)
SM2_EncString.restypes=(c_int)
##���ַ�������SM2����
SM2_DecString=Psyuunew.SM2_DecString
SM2_DecString.argtypes=(c_char_p,c_char_p,c_char_p ,c_char_p)
SM2_DecString.restypes=(c_int)
##����Ϣ����SM2ǩ��
YtSign=Psyuunew.YtSign
YtSign.argtypes=(c_char_p , c_char_p ,c_char_p ,c_char_p)
YtSign.restypes=(c_int)
##��SM2ǩ��������ǩ
YtVerfiy=Psyuunew.YtVerfiy
YtVerfiy.argtypes=(c_char_p,c_char_p,c_char_p,c_char_p,c_char_p,c_void_p,c_char_p)
YtVerfiy.restypes=(c_int)
##SM2�㷨��ʼ��(ʹ������)
IniSM2=Psyuunew.IniSM2
IniSM2.restypes=(c_int)
##���ַ�������SM2����(ʹ������)
SM2EncString=Psyuunew.SM2EncString
SM2EncString.argtypes=(c_char_p,c_char_p,c_char_p ,c_char_p)
SM2EncString.restypes=(c_int)
##���ַ�������SM2���ܣ�ʹ��������
SM2DecString=Psyuunew.SM2DecString
SM2DecString.argtypes=(c_char_p,c_char_p,c_char_p)
SM2DecString.restypes=(c_int)
##����Ϣ����SM2ǩ����ʹ��������
SM2Sign=Psyuunew.SM2Sign
SM2Sign.argtypes=(c_char_p , c_char_p ,c_int ,c_char_p ,c_char_p)
SM2Sign.restypes=(c_int)
##��SM2ǩ��������ǩ��ʹ��������
SM2Verfiy=Psyuunew.SM2Verfiy
SM2Verfiy.argtypes=(c_char_p,c_char_p,c_char_p,c_char_p,c_char_p)
SM2Verfiy.restypes=(c_int)
##�ͷ�SM2�㷨(ʹ������)
ReleaseSM2=Psyuunew.ReleaseSM2
##��������Ӳ��оƬΨһID
GetChipID=Psyuunew.GetChipID
GetChipID.argtypes=(c_char_p,c_char_p)
GetChipID.restypes=(c_int)
##���Ϻ���ֻ֧������оƬ����
##���º���ֻ֧��D8
CheckDate=Psyuunew.CheckDate
CheckDate.argtypes=(c_char_p,c_char_p)
CheckDate.restypes=(c_int)
##���Ϻ���ֻ֧��D8
if 'Linux' in platform.system():
CloseUsbHandle=Psyuunew.CloseUsbHandle
CloseUsbHandle.argtype=c_char_p
CloseUsbHandle.restypes=(c_void_p)
def CheckDateEx(Path):
dt=datetime.now()
nowDate=dt.strftime( '%Y/%m/%d/%H/%M/%S' )
ret=CheckDate(nowDate.encode('utf-8'),Path)
return ret
def HexStringToByteArrayEx(InString):
mylen=len(InString)
array_data={}
in_data=c_byte
temp=''
for n in range(0,mylen,2):
temp=InString[n:2+n]
temp='0x'.encode()+temp
in_data=int(temp,16)
array_data[n/2]=(in_data)
return array_data
def StringToByteArray(InString):
mylen=len(InString)
array_data={}
in_data=c_int
temp=''
for n in range(0,mylen):
temp=InString[n:1+n]
in_data=ord(temp)
array_data[n]=(in_data)
array_data[n+1]=0
return array_data
def ByteArrayToString(InBuf):
arrBytes = bytearray()
for n in range(0,len(InBuf)):
arrBytes.append(InBuf[n])
return arrBytes.decode()
def ByteArrayToHexString(in_data,inlen):
OutString=''
temp=''
for n in range(0,inlen):
temp='%02X' % in_data[n]
OutString=OutString+temp
return OutString
def EnCode(InData,Key,pos):
KeyBuf=HexStringToByteArrayEx(Key)
OutData=EncBySoft(InData,KeyBuf,pos)
return OutData
def DeCode(InData,Key,pos):
KeyBuf=HexStringToByteArrayEx(Key)
OutData=DecBySoft(InData,KeyBuf,pos)
return OutData
def EncBySoft(inb, KeyBuf,pos):
bufArray=c_uint32*16
buf=bufArray
temp_string=''
cnDelta = 2654435769
_sum = 0
a = 0
b = 0
c = 0
d = 0
for n in range(0,4):
a = (KeyBuf[n] << (n * 8)) | a
b = (KeyBuf[n + 4] << (n * 8)) | b
c = (KeyBuf[n + 4 + 4] << (n * 8)) | c
d = (KeyBuf[n + 4 + 4 + 4] << (n * 8)) | d
y = 0
z = 0
for n in range(0,4):
temp = (inb[pos +n])
y = (temp << (n * 8)) | y
temp = (inb[pos +n + 4])
z = (temp << (n * 8)) | z
n = 32
while n > 0:
_sum = (cnDelta + _sum) & 0xffffffff
temp=(z << 4) & 0xffffffff
temp=(temp+a)& 0xffffffff
temp_1= (z + _sum) & 0xffffffff
temp_2=((z >> 5) + b)& 0xffffffff
temp=temp ^ temp_1 ^ temp_2
y = (y+ temp)& 0xffffffff
temp=(y << 4)& 0xffffffff
temp=(temp + c)& 0xffffffff
temp_1=(y + _sum)& 0xffffffff
temp_2=((y >> 5) + d)& 0xffffffff
temp=temp ^ temp_1 ^ temp_2
z=(z+temp)& 0xffffffff
n = n - 1
outb={}
for n in range(0,4):
outb [n]= (y >> (n) * 8) & 255
outb[n + 4] = (z >> (n) * 8) & 255
return outb
def DecBySoft(inb, KeyBuf,pos):
bufArray=c_uint32*16
buf=bufArray
temp_string=''
cnDelta = 2654435769
_sum = 0xC6EF3720
a = 0
b = 0
c = 0
d = 0
for n in range(0,4):
a = (KeyBuf[n] << (n * 8)) | a
b = (KeyBuf[n + 4] << (n * 8)) | b
c = (KeyBuf[n + 4 + 4] << (n * 8)) | c
d = (KeyBuf[n + 4 + 4 + 4] << (n * 8)) | d
y = 0
z = 0
for n in range(0,4):
temp = (inb[pos +n])
y = (temp << (n * 8)) | y
temp = inb[pos +n + 4]
z = (temp << (n * 8)) | z
n = 32
while n > 0:
temp=(y << 4)
temp= ( temp+ c) & 0xffffffff
temp_1=(y + _sum)& 0xffffffff
temp_2=((y >> 5) + d)& 0xffffffff
temp= temp ^ temp_1 ^ temp_2
z=(z-temp) & 0xffffffff
#z -= ((y << 4) + c) ^ (y + _sum) ^ ((y >> 5) + d)
temp=(z << 4)& 0xffffffff
temp=(temp+a)& 0xffffffff
temp_1=(z + _sum)& 0xffffffff
temp_2=((z >> 5) + b)& 0xffffffff
temp= temp ^ temp_1 ^ temp_2
y = (y -temp)& 0xffffffff
_sum = (_sum -cnDelta)& 0xffffffff
n = n - 1
outb={}
for n in range(0,4):
outb[n] = (y >> (n) * 8) & 255
outb[n + 4] = (z >> (n) * 8) & 255
return outb
def StrDec(InString,Key):
OutBuf={}
mylen=len(InString)/2
KeyBuf=HexStringToByteArrayEx(Key)
InBuf=HexStringToByteArrayEx(InString)
for n in range(0,(mylen-8)+1,8):
tempBuf=DecBySoft(InBuf,KeyBuf,n)
for i in range(0,8):
OutBuf[i+ n] = tempBuf[i]
if mylen>8:
n=len(OutBuf)-1
for n in range(len(OutBuf),mylen):
OutBuf[n]=(InBuf[n])
return ByteArrayToString(OutBuf)
def StrEnc(InString,Key):
OutBuf={}
InBuf={}
temp_Buf=InString.encode('utf-8')
mylen=len(InString)+1
for n in range(0,mylen-1):
InBuf[n]=temp_Buf[n]
InBuf[n+1]=(0)
if mylen<8:
for n in range(mylen,8):
InBuf[n]=(0)
mylen=8
KeyBuf=HexStringToByteArrayEx(Key)
for n in range(0,(mylen-8)+1,8):
tempBuf=EncBySoft(InBuf,KeyBuf,n)
for i in range(0,8):
OutBuf[i+ n] = tempBuf[i]
if mylen>8:
n=len(OutBuf)-1
for n in range(len(OutBuf),mylen-1):
OutBuf[n]=(InBuf[n])
OutBuf[n+1]=0
OutString=ByteArrayToHexString(OutBuf,mylen)
return OutString
#ʹ����ǿ�㷨������Ƿ���ڶ�Ӧ�ļ�����
def CheckKeyByEncstring_New():
DevicePath=create_string_buffer(260)
EncInString=["22128","29496","13134","26562","17476","14629","21328","21094","17506","6324","13549","19640","6132","30309","12958","12107","32068","16221","3328","8272","18876","7005","21705","21913","9191","16070","29910","30362","23917","23706", \
"23584","7780","27929","14460","18370","32167","2263","22702","11509","7352","24493","22545","17170","15750","29640","22569","11669","23974","5234","4886","17943","22600","30738","3482","1619","10303","30261","26903","4641","18941", \
"24965","21905","24955","15763","459","9129","2686","10420","11761","30367","11106","6321","1537","5720","29824","25725","19748","24916","21076","11946","25510","24245","14199","1897","24817","28734","1699","11917","19853","9298", \
"7346","30087","32037","10225","31390","16746","2181","22716","3970","11496","26515","30456","8855","19026","11100","30597","23862","1436","22537","30182","29914","9813","24292","17982","29982","29105","14423","10060","10684","27778", \
"7661","5236","10380","15674","25678","14263","31625","11754","30021","31672","27341","20037","27069","15801","26259","13724","17343","8092","4404","25826","18549","31201","26921","18601","31273","28077","4879","23330","12870","5825", \
"17308","26144","23380","23934","18862","25876","19198","26854","14396","1810","15375","12445","12385","20681","26735","12003","19288","24205","17194","12954","9338","18001","21097","20805","833","6565","10615","30981","9542","1979", \
"700","8862","10310","8038","31171","9072","5144","12567","25910","8062","1207","20705","20704","7017","29757","30837","6058","11892","9445","18727","7582","21632","11016","28135","10726","24592","5920","7496","24780","3142", \
"16326","15227","23994","12003","11190","7251","27962","2634","7114","25921","26359","16253","13562","3929","10170","24605","19041","2379","11116","8301","18233","31080","18201","10574","14557","8102","747","2628","30918","22419", \
"5162","19310","30349","14948","30528","8080","8687","24808","10682","13836","29891","17812","1088","11492","7429","18040","13467","8889","18125","18247","22454","26829","1623","29522","13213","21764","25083","8077","4471","13278", \
"31796","19591","14223","23166","23965","18548","847","22693","24304","28966","9025","19126","13061","5647","28943","19379","4312","31295","27524","1853","32128","30315","20617","27542","13883","15076","22312","31650","14945","12699", \
"2443","16609","30059","35","16124","23926","2294","10669","13797","15906","14009","20748","19920","27720","27278","6833","24936","32745","25714","11951","16501","12713","637","23224","18915","3272","10984","21533","9659","16680", \
"22030","6610","7975","5453","14442","30310","7793","30806","3222","8718","17155","13319","32073","1178","7528","16066","12129","6012","2377","11657","27604","26567","10095","17917","27072","14381","30661","12385","14429","17151", \
"4951","18838","18692","7216","1612","5408","6450","13138","18926","20254","31869","30101","24233","7765","1699","4047","1543","26148","5499","20590","7345","14480","31487","10631","5232","26681","18252","21193","3632","14946", \
"12954","2953","5114","14572","10050","31926","29431","9307","27584","15077","13684","1487","27821","26694","15576","24841","9923","30380","31662","1647","12508","2441","20385","1279","26098","30702","31609","15453","12064","28301", \
"16674","3787","28062","12730","7077","13099","1225","32613","6444","9982","1047","4385","21761","16486","28964","15903","4495","24614","12716","15666","29277","17312","5510","1740","22041","30422","174","22269","20619","26217", \
"13628","20346","17564","4508","15723","14740","7769","23632","30101","26683","11496","265","13878","14852","7319","8934","7653","15136","4301","32683","31580","26463","24085","16827","22392","3126","25625","29205","7984","19125", \
"1956","2654","28063","14735","19615","9941","30208","10005","4116","22622","3500","31546","25132","5756","22044","14736","52","20814","1773","9032"]
EncOutString=["CFA5FE777DC2BC7B","44CC739E5A0AD0FD","F899C13ED9551C22","88C9F8A3851867D3","4A8582E27FD9DC67","3B0C85F79C0477BC","0D9F86729D31401A","FF5F672C74542BE6","A52B65507CDA6FB8","904B249FB4829280","F0E7DDF11001ABC9","D484E5FFC963D8BF","EF6A770444EAF909","57F04E9FE1BA3FD8","E44C761A27CEAA6D","214011B85BC93CD5","ECC2BE37F0A7CC70","5F67939A60A91731","158C60D62860EB3E","F9AF015E39140554","C541B957DA510B57","09141D471E3DA317","80A9C10B7A936931","86D48EB13DE8FAFD","F6E091745A514880","AD9C6FBE675DDE34","90624792C9C13206","7D2FA019033BB15A","E607F1BEBB969730","EF883C1C09EBDFB6", \
"FC5DA492706FFD97","DC157A70336D5485","C5791500EED7D0C0","1419486CB24F7B84","A85B373EB338BEF0","3BFDC24552DC6869","83292730338867C4","F959B81CEB38B033","D32A108599F419CF","25703A615B3D233B","48F59647DC4DAD4A","1CBE22F872F94D59","E66481AF23455FFE","A2CF111CCF0F90F6","9E060B68D27F6471","7AA7F68A20781E04","D42B9534E35545FF","690BB1D3A234DE47","47537F5307511545","DF1A23A328DFD8EE","2BB952E497AFCB23","6248AB81BD46DB9C","87C45B0FAA3D56DD","5D520D1F1F3E3E0F","4DADC23C11C3185A","EE76D9CFB5E08DBC","43479B4306255A11","AB7EDF7F7ED985D5","1F9FF1783CAD8D7C","B33177574A51197F", \
"C45DFD5FACF18277","D121ED1B1AC249F0","12BE5DA679D438C8","079CEAF5B39D1D95","302F2CB2A81D910A","BFC705D80BA6C0FE","E6CD51636DBE8B43","DF73BEA5B3E6F6B4","29E061BE84B23983","8D0AD2EC2B4C3E45","D2B2E7171157C05A","42B17459DCA82D2A","4DB04A2BC1611CF0","8D8711A7F88A70E0","66EF0ABDEB85D042","A5E94512F4312EBF","43CFDEA0A91C56E5","1072ACFB9083C31B","92D165AAA37BA96A","6C4465C69014DDA2","E036BAFB250DE30F","57D033AED1D43A4F","E5CF1891A692551E","2E0355E70EFFEAD2","AAB895BF3AA49F77","900501A8C0E13A26","E5C5D718EC6EC3F6","4BD7B10B427396FF","F15CF42D89326540","78B02DA8170C8443", \
"99A3B6F619246817","E60AD2D10D1BFB9F","0AA6472EB1ED0398","0FBA22CE10EF7D82","452AAD535259F35A","FFA23D9FB431A7C0","C70024F4209BAE45","85D989DB6CF42AD7","8424212FA20F79D3","A4B2F0295C9E2C14","F4C6D62B04DFE42E","2805A5076B02A255","E03DEA5FFC819E4D","59CA29FFE5D74BBC","283DE843AC609309","66336BABC6D1AF46","32E4165BECA69384","AEC1E80263D8AE17","4E4ABDF72E70E74D","0BBCB346796A6CA2","AF0A7400F81B830A","62D5BDE717D7B0A3","8C4CC1648999341C","2CB2F8F5222C69D9","56AE1FC179F4691B","59289EE6B5C3B83C","45A05BF94122DB41","6906AC9FDD7A86E6","538A090961E32024","9ED08BF21EDAE659", \
"23FA7CB4DCD962E3","AE4B851DD388F3F3","31DFAFB538203227","D4873E475DCB2680","F15E3D7A5D0D8661","FEF3F1068A1A3F59","D6CE5E515A548187","24C1833FDDF0ED0E","FC11B0427132349C","613125596918DC71","951E0EA36138FAD0","DC6381115DD5756D","CB91A0DF6779B8EC","10A918DF8F64D2F1","A674613187569D01","91325980C90DD689","CAF4B366DF8CE0B6","6889904712A8E2C6","0D0590FB59A81048","3B22E50E4EB48221","B3EDDC7EE7193FDE","05D3476144AF62D9","9BF24495C71E6E41","1D3A890B7189998F","F84C9EE56F21B876","5C0E670EE62E2FBD","2A4CA6B86053A516","D23BBCA50E6D5D09","80A13D68D3B70F4F","203D4A48B7C70202", \
"77E0987A7B28B412","34F36FC1E9B0606D","1B0BE2DB2539A0DE","895F297219E37293","A8D7A559994175D6","59641FC84612978A","700909835367DF77","F608040DC74A9FF6","5C0E5E35C94CBF5F","4C0043522D604D16","7A86FC128C76A915","C87D2F5265A94CDE","34040B31C730EB23","E7FB69C6278BB0DC","B09704DDF15382DA","02BBE2A95107D57C","D39B53C38768A568","6D53FB813B47A275","A751CE9C9764BB2A","B9AD286B56B458A8","2A73038247ADC81F","8A060D49361023E6","229BB5537061FA9A","BF85B927F833C03F","AB659C6F90DB3298","54986E55FFFCF30D","2FCBCA07195CBDAF","6C23E5D9C833CEC7","87960A6AE63E40F9","1625BFDCA435AF13", \
"A55D176ECD240C8B","BD767A4AFF96AEE8","A77EE39253159DBC","128B3B9F4302E146","8E16856B0DDDB26B","6E9BF08A6D4445E2","2BF2F072D52EBE27","27766687DAF0BF45","3433B8B274F09F0C","8C5C3F62D6E11590","3E46EE812B4970C7","632C333541734408","0012F0B2CCE761ED","1FAB4F6EDE9A78DB","409B816B06FBEA35","EEF3573529E71273","56142C951DE0413D","638C8067BC04F392","3889C5C7A265B4DA","E559D3BBEC7A2B63","23194DBA569246DF","6DE909486E941630","1B7D29EAD296DADB","AFB2AF61178DE9B8","C61F36E21227BB42","B31449DA15C80F04","10972FFA7E67B455","5330EA69E7D3A155","AD27CD3E46823C6E","5772DC6624F32F23", \
"BF082996855F63F5","D2551216B1C603C6","EFF32D646ABA5146","02BBE2A95107D57C","CBA8FA2488C533B5","E0A537B87CAD31CD","AADD1E5FF433636E","9C98BD75A894FC0D","175380D96D8D8CD5","BEAAECCCB107E1F8","5E321A336C1FCBED","0188B4178DF24EB3","D25EA4DF43DD6764","9963912DFFAE722C","88B95C5E4CDE4FF4","2ACFE1F463AB51A2","009EC39124093800","0933A8B8BDCA2E8E","0D55116B8F16D439","081FC397E397F8AC","3644824A83E55D15","C31F059D831DAAC8","0E6C5C7EECE235AE","50C728DFB4F61EED","6DEAF0A51E012A4D","4B596B1202024EB5","4E1B622D806AA501","72B029C7E8ED56D0","75AE04BDCD0C2725","DAFB1CEFAA153E63", \
"EDB5323B0FA5DB31","139571B5C7882C92","FC0DDE34CCCA3F0C","7D1AA46CF45C447A","403F9923D38D226F","A156C02D6F6F4207","8F79738E1BCC23C0","451A1BFACF5BB149","3821949F5313B79B","B9CB8EBF2F926126","2F810B7DF2633641","F78F2CB7A1AC9523","A58218472A04FF35","5704AFC3B93FF453","EFF880522BC6BD9E","B685BD4C6C89628F","3D8D0F53B4ECD8AB","F7CE1DDCC28EBED9","E43EA06D350B30F8","2B88F3071183876E","0B95364DF5C511FE","094F20C85FC24442","8A082748B960F95F","FDE800482BCA74F8","F5CC40ECBDDCE36F","8B0DBE932255D388","6AC85BD4ECC8098A","7B43801212B2B86A","6272E527CC554AE2","95E2E29E08606D25", \
"87E2E7DA0E6F9AE3","CDDE9D43DBA1BF42","BCB875714C5AFAD9","BF7F37D2645FEDCC","7B37BA7CF4F093F0","7745EA1B14895D8B","C4B053E766EC59BB","076BB5368EE833B7","B58B097A27FBA13D","A6818FCE74444637","234F6DE36D6135AA","F93AE4F64BBA85E1","D21FE040FC1888E6","B50B725265A4A7CB","EDA8DF048844C858","1458CCE4024A052B","65007F73EF0A1718","A57EC3B1E334594B","9113F9BFAEFA6E7D","AA0EA6C445E52B3C","F3FBA318A7297B9C","E8490F72F3D8AC76","CD0FA677E9CE6A35","ECC1F6C9B146817C","39242405BB9B2700","C022AFDADE92011E","13615B49BA3D42BD","FAC07B329F92E015","840C5ED65E1C2943","9FEDFD3A5B1DA38A", \
"103F3C4346D712A9","FEC3B993D813ED7C","AF34A0BB7D8311D9","E567003B7736CBE5","CC24FDC91CC3B171","9867302B77C34B5B","10C5D3C6C4C719CD","242F1C616B952B15","CA7AC8234847771D","9205F2924CD88B5C","A38D8D146AE535E8","1FD2391909782870","BA6FD84CDC102987","1AFD6B63AE15B67E","0D3BC910BBFC9B52","9083C6C34958520D","9E886BFC12811906","D4C84BE2F7D46074","C48FE01EFA774C39","FB1A47C32E096C29","FDACFE5CB437B623","0CC41514F23ED235","F4461F7DD038257E","A4388F569A7C1B1C","697958B6A44F851D","FE68C4AD30C86E0E","A7186EC6934FB1D7","7C6670A45BC56F0D","FDA13B04E135BF4E","5F221638ACCF5DAC", \
"9C8F1363482C94B5","87258236D81D9249","CA5D09A2C27FC74D","2362836E7C1211B9","F4A336888C9BC45E","99D81FF4843943B7","6FB827A91EC49978","9F0412ADD1D92A13","5E724AF5814995E0","22DE60F466548005","77667222093A59A2","798B13392C4C24E2","C358A9B283EF0DF7","0DE4B91F77C7D618","522444A42E59B8AB","8EF221BE3B2F8E3E","7181256EA8F75A2F","150EA219B59D70EA","D4C3A80C677176A2","52E08DB0CF299389","02013194C02DBA9A","BA5429F47E799D31","7CDCF3E536C66440","D0BAA8794B309154","BAB890923277A1EA","13A6B82D3FA71D09","2BD153E8A526F676","34040B31C730EB23","6B22CBEA4A410FE5","A8458516ABC45DBA", \
"E81EE8C134B968B2","BC2CC4A150DE04C2","7812FF04B85A0C02","6762F05A5FEAC0DE","A4C3123B5670AC75","5B57DF03D5CE335E","95DDCDD2AD0C5F24","E1CDF0F64B66CB76","6708D59CE2FF1209","4AF87F93678AB8D9","E7AD2A33F3BD4F81","BE6EBD332452F958","4BBD10FFB4B4113C","DC003D51289DFF49","E5C5D718EC6EC3F6","BE18BE0D1828CCF5","E44A223E0A6380A3","668A96491651C53D","0F3727D20C2346C4","2AA5CD407E87181C","40A117959B085BCC","F31198993FB89E8A","132929E135F89166","F9C11ACA479F5068","7CED6A15DD8D9529","7CB7C3365121F74E","41FAEE8E4A53AE08","A8963556D144B270","9B19366829DBDB22","BA35A66DC4BDB244", \
"B9AD286B56B458A8","2AC45F24B58BFFC7","FAAFE7EE4E6CC01E","364F41D6770DCF02","4819615DF2E9CC29","15BB09D7F88B49A9","DA53CF9F484A3570","54B773DA9F015D4A","8AB3EE7B6619B6C2","A8DA3E47A4BA4CA8","BAB49DDAC3A69156","BC191C2CA8BF5975","E376A2D85CE00C21","3E2BC5930D1C0D4F","9A09FE24EFC4582C","D106091F6EF52490","778DBF924BA90F86","C2EC35025452FD24","440D3D9B7F0E0C20","C0CC9D99D7730C1C","44776AB346C92FA3","E843CBED39E97F16","BB619EC199FC7CAA","56BFF900DBAC2155","EB8CE67FAF6A5367","D22D153C81F1C09A","BA4B3B4D13BA5338","F0BCC8CEF2AFF2EB","679643306314041D","2D292F09220E42EE", \
"6B4384ADFFDB004D","15AB139CA5E53C27","584A5913FF4956C8","839D03B45D600DD1","F862DFA5B7036CBB","B7CBD3C01149B2D2","F17A6C580BF2A657","57A40D5C82B1F7E6","86FF1931FA492C04","9F68C19F5C24D378","96BFDC80FC149357","44CF3E2E354543DB","67D8037745144962","DA697D967D554EC1","B800E40A74BEBD76","D76341895B0A7C1D","17F78023F95ABE7D","32BB976FEBAA679A","E0480BC8E1F2BB91","62F91E5FEF7D0E19","A3F9F804055F6857","C440629BE0B15A14","67BF4891DEE7B076","D85FD3A5362F835B","93F7A3E37304D8E3","C3E20946707AFEA3","4FD0A7DDDEEDEB3E","53D76C52982AABFE","91E267D10D9081FA","279BDF8AD992269C", \
"36961542D35B63BF","A7B4543875346904","639EF19414884E2E","3667B72DDAB06025","D7E34290727FFFE6","D0468C8FA6A0A6A8","92703AEDB72A596F","5E4ACD3930EF4B3A","BE6EBD332452F958","A11B3A058D1FB0B4","A4B2F0295C9E2C14","CE670A8014BEF5BE","2E2E226E4D88C306","36B132A93312B5DF","F3692EA7F5083300","1B6B1D413E4DDA71","91F6AEAC50C2831B","9D160A344B2B606D","8404818915AAD0F0","2E7E821DE5047DDC","FE01D0F6DBEC604B","12BCFD63FA5B4F9B","3ADB05AE89D39FE4","889CD8B4C4D808FB","3CB70121DCEAB136","F7790077AC6E13B8","7E68B4C8A6F3DB3C","92D851C715FAF55A","4EA7A87A5033E61B","83F287E4B4D9DFB0", \
"0194ACCAE701866E","49744AA812C00A2E","A4D1BA14748B8B61","8C79C0FCBB553842","544BD977BC00748D","058934FB3BDC293E","E03D223F33E7B2C3","7A1356B6D0757D30","91DC5D7AD773DFD5","206A0E0C7FEA3F59","870DBCBA19884B29","99430CC28ACD7323","06C04ACD41D93448","1A6DB4C18117FCAF","1B1A6BA91F147E7A","DD662B39B87B1740","346723FEAD39B143","65D43D985876041E","3799A75F167F0004","04D2588FC395289E"]
#@NoUseNewKeyEx return 1 #���û��ʹ��������ܣ�ֱ�ӷ���1
#@NoSupNewKeyEx return 2 #��������֧��������ܣ�ֱ�ӷ���2
myrnd=random.randint(1, (500 -1 ))
mylen = len(EncInString[myrnd])+1
if mylen < 8 :
mylen = 8
outstring = create_string_buffer((mylen* 2+1))#//ע�⣬����Ҫ??һ�����ȣ����ڴ������ѧ����
for n in range(0,255):
ret=FindPort(n,DevicePath)
if ret!=0:
CloseDongle(DevicePath)
return ret
ret=EncString_New(EncInString[myrnd].encode('utf-8'), outstring,DevicePath)
if outstring.value.decode('utf-8').lower()==EncOutString[myrnd].lower():
CloseDongle(DevicePath)
return 0
CloseDongle(DevicePath)
return -92
#ʹ����ǿ�㷨һ�����������������������Ч�ط�ֹ����
def CheckKeyByEncstring():
#�Ƽ����ܷ�����������������������������㣬ͬʱ�ڳ����ж�ʹ�ô�����ͬ���ļ������㣬Ȼ����бȽ��жϡ�
DevicePath=create_string_buffer(260)
#@NoUseKeyEx return 1 #���û��ʹ��������ܣ�ֱ�ӷ���1
InString=('%X%X' % ((int)(random.uniform(0, 24174836)),(int)(random.uniform(0, 24174836))))
for n in range(0,255):
ret=FindPort(n,DevicePath)
if ret!=0 :
CloseDongle(DevicePath)
return ret
if Sub_CheckKeyByEncstring(InString,DevicePath)==0:
CloseDongle(DevicePath)
return 0
return -92
def Sub_CheckKeyByEncstring(InString,DevicePath):
#//'ʹ����ǿ�㷨���ַ������м���
nlen = len(InString) + 1
if nlen < 8 :
nlen = 8
outstring = create_string_buffer((nlen * 2+1))#//ע�⣬����Ҫ��1һ�����ȣ����ڴ������ѧ��??
outstring = StrEnc(InString, 'D31B2D928A62607E3E6ACD1165843D8E'.encode('utf-8'))
outstring_2 = create_string_buffer((nlen * 2+1))#//ע�⣬����Ҫ��1һ�����ȣ����ڴ������ѧ��??
EncString(InString.encode('utf-8'),outstring_2,DevicePath)
if outstring.lower()==outstring_2.value.decode('utf-8').lower():#//�ȽϽ���Ƿ����
ret=0
else:
ret=-92
return ret
#//ʹ�ô����ȵķ�����ָ���ĵ�ַ��ȡ�ַ���
def ReadStringEx(addr,DevicePath):
InArray=c_ubyte*1
blen = InArray(0)
#//�ȴӵ�ַ0������ǰд����ַ����ij�??
ret = YReadEx(blen, addr, 1, 'BD1B62F3'.encode('utf-8'), '7621A856'.encode('utf-8'), DevicePath)
if ret != 0 :
return ''
outstring=create_string_buffer(blen[0])
#�ٴӵ�ַ1��ȡָ�����ȵ��ַ���
ret = YReadString(outstring, addr+1, blen[0], 'BD1B62F3'.encode('utf-8'), '7621A856'.encode('utf-8'), DevicePath)
if ret!=0:
return ''
return outstring.value
#//ʹ�ôӴ�������ȡ��Ӧ���ݵķ�ʽ����Ƿ����ָ���ļ�����
def CheckKeyByReadEprom():
DevicePath=create_string_buffer(260)
#@NoUseCode_data return 1 #���û��ʹ��������ܣ�ֱ�ӷ���1
for n in range(0,255):
ret=FindPort(n,DevicePath)
if ret!=0 :
CloseDongle(DevicePath)
return ret
outstring=ReadStringEx(0,DevicePath)
if(outstring=='TGX-08-0003#B1084CF7-A763-49DA-A7B5-6E88F7D131B8#241324F9-8563-424D-9E98-8DDAFE105EA5'.encode('utf-8')):
CloseDongle(DevicePath)
return 0
CloseDongle(DevicePath)
return -92
#ʹ����ͨ�㷨һ����ָ���ļ�����
def CheckKeyByFindort_2():
DevicePath=create_string_buffer(260)
ret=FindPort_2(0, 1, -500811555, DevicePath)
CloseDongle(DevicePath)
return ret
def CloseDongle(DevicePath):
if 'Linux' in platform.system():
CloseUsbHandle(DevicePath)#�ر�USB�豸