工具箱相关
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

加密文本.py 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. import os
  2. from sympy import *
  3. import uuid
  4. import time
  5. import math
  6. import re
  7. import arcpy
  8. def dataGet(s0):
  9. aa = 0
  10. datekey = {
  11. 'ze':'0','im':'1','tw':'2','ee':'3','fr':'4','ve':'5',
  12. 'ix':'6','se':'7','ei':'8','ni':'9'
  13. }
  14. ii = 0
  15. dastr = []
  16. while ii < 8:
  17. x1 = 2 * ii
  18. y1 = x1 + 2
  19. das = datekey[s0[x1:y1]]
  20. dastr.append(das)
  21. ii = ii + 1
  22. datestr = ''.join(dastr)
  23. mm = int(datestr[:2])
  24. dd = int(datestr[2:4])
  25. yy = int(datestr[4:])
  26. tm = time.localtime()
  27. dy = int(tm.tm_year)
  28. dm = int(tm.tm_mon)
  29. dday=int(tm.tm_mday)
  30. if dy < yy:
  31. aa = 1.7
  32. elif dy == yy:
  33. if dm < mm:
  34. aa = 1.7
  35. elif dm == mm:
  36. if dday <= dd:
  37. aa = 1.7
  38. else:
  39. aa = -3
  40. else:
  41. aa = -3
  42. else:
  43. aa = -3
  44. return aa
  45. def macget(sy0,ma0):
  46. mackey = {
  47. 'a':'10','b':'11','c':'12','d':'13','e':'14','f':'15'
  48. }
  49. aa = 0
  50. sy = list(sy0)
  51. ma = list(ma0)
  52. ii = 0
  53. node = uuid.getnode()
  54. MAC = uuid.UUID(int = node).hex[-12:]
  55. mac = MAC.lower()
  56. while ii < 4:
  57. try:
  58. syi = int(sy[ii])
  59. mai = ma[ii]
  60. maci = mac[syi]
  61. if maci == mai:
  62. aa = 0
  63. else:
  64. aa = -2
  65. break
  66. except:
  67. syi = int(mackey[sy[ii]])
  68. mai = ma[ii]
  69. maci = mac[syi]
  70. if maci == mai:
  71. aa = 0
  72. else:
  73. aa = -2
  74. break
  75. ii = ii + 1
  76. if aa == 0:
  77. aa = 1.7
  78. else:
  79. aa = -2
  80. return aa
  81. def pdd(kk):
  82. n = Symbol('n')
  83. if kk > limit(((3*n*n - 5)/(2*n*n + n)),n,oo) and kk < (integrate(n**2,[n,0,1]) * 6):
  84. # ----------------这句才是程序运行代码----------------------------------
  85. listfile(arcpy.GetParameterAsText(0),arcpy.GetParameterAsText(1))
  86. # ----------------这句才是程序运行代码----------------------------------
  87. elif kk == -1:
  88. arcpy.AddMessage ('\n')
  89. arcpy.AddMessage ('The License File Does Not Exist!')
  90. arcpy.AddMessage ('\n')
  91. elif kk == -2:
  92. arcpy.AddMessage ('License Password Error!')
  93. elif kk == -3:
  94. arcpy.AddMessage ('Out Of Permitted Time!')
  95. else:
  96. arcpy.AddMessage ('License File Corrupted!')
  97. def bsfGet(s0):
  98. aa = 0
  99. bsfkey = {
  100. 'bd':'a','cd':'c','7a':'d','ae':'e','97':'g','6k':'h',
  101. '57':'i','22':'D','2c':'m','8m':'o','3w':'p','11':'I',
  102. '5d':'r','4u':'s','9t':'t','au':'u','23':'x','yk':'y',
  103. 'za':'z','k4':'0','v6':'1','tw':'2','h0':'5','op':'7',
  104. 'po':'8','wt':'9','8x':':','yy':',','lo':' ',
  105. }
  106. ii = 0
  107. lens0 = len(s0)
  108. bsfstr = []
  109. while ii < (lens0 / 2):
  110. x1 = 2 * ii
  111. y1 = x1 + 2
  112. bsf = bsfkey[s0[x1:y1]]
  113. bsfstr.append(bsf)
  114. ii = ii + 1
  115. bsstr = ''.join(bsfstr)
  116. return bsstr
  117. def licen():
  118. aa = 0
  119. linsy = ''
  120. linma = ''
  121. s1 = 'aucd8x'
  122. s2 = '3w5d8m7aaucd9tlo11228x'
  123. s3 = 'cd573w6kae5d8x'
  124. # path = 'D:\\CMCtbxLisence\\tbxLisence.txt'
  125. # isExists=os.path.exists(path)
  126. # if not isExists:
  127. # path1 = 'E:\\CMCtbxLisence\\tbxLisence.txt'
  128. # isExists1=os.path.exists(path1)
  129. # if not isExists1:
  130. # path2 = 'F:\\CMCtbxLisence\\tbxLisence.txt'
  131. # isExists2=os.path.exists(path2)
  132. # if not isExists2:
  133. # aa = -1
  134. # else:
  135. # outpath = 'F:\\CMCtbxLisence\\tbxLisence.txt'
  136. # else:
  137. # outpath = 'E:\\CMCtbxLisence\\tbxLisence.txt'
  138. # else:
  139. # outpath = 'D:\\CMCtbxLisence\\tbxLisence.txt'
  140. outpath = os.path.expandvars("%APPDATA%") + '\\CMCtbxLisence\\tbxLisence.txt'
  141. isExists = os.path.exists(outpath)
  142. if not isExists:
  143. aa = -1
  144. if aa != -1:
  145. with open(outpath,'r') as lines:
  146. for line in lines:
  147. t = bsfGet(s1)
  148. if re.search(bsfGet(s1),line):
  149. try:
  150. linrq1 = line.split(':',-1)[-1]
  151. linrq = linrq1.replace('\n','')
  152. aa = dataGet(linrq)
  153. if aa == -3:
  154. break
  155. except:
  156. aa = -9999
  157. if re.search(bsfGet(s2),line):
  158. try:
  159. linSY1 = line.split('-',-1)[-1]
  160. linSY = linSY1.replace('\n','')
  161. linsy = linSY.lower()
  162. except:
  163. aa = -9999
  164. if re.search(bsfGet(s3),line):
  165. try:
  166. linma1 = line.split('-',-1)[0]
  167. linMA1 = linma1.split(':',-1)[-1]
  168. linMA = linMA1.replace('\n','')
  169. linma = linMA.lower()
  170. aa = macget(linsy,linma)
  171. except:
  172. aa = -9999
  173. else:
  174. aa = -1
  175. pdd(aa)
  176. if __name__ == '__main__':
  177. try:
  178. arcpy.AddMessage ('start at {0}\n'.format(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())))
  179. licen()
  180. arcpy.AddMessage ('end at {0}\n'.format(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())))
  181. except arcpy.ExecuteError:
  182. arcpy.AddMessage (arcpy.GetMessages())