Advertisement
Guest User

Untitled

a guest
May 19th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.54 KB | None | 0 0
  1.  
  2. print('----------Wszyfr----------')
  3.  
  4. print("Zestaw 1")
  5.  
  6. tests = 0
  7. testf = 0
  8. testc = 0
  9.  
  10. for i in range(0, 100):
  11.     iv = '0' * 20
  12.     p = '0' * 20
  13.     e = Wszyfr.szyfrowanie(iv, p)
  14.     n = len(e)
  15.     if Serial.test(3, n, e) is True:
  16.         tests += 1
  17.     if Freq.test(e, 40, n) is True:
  18.         testf += 1
  19.     if CuSum.test(e, n, 0) is True:
  20.         testc += 1
  21.  
  22. print("Na 100 prob")
  23. print(
  24.     "Losowych ciagow wedlug test Serial: {} /Freq: {} /CuSum: {}".format(
  25.         tests, testf, testc
  26.     )
  27. )
  28.  
  29.  
  30. print("Zestaw 2")
  31.  
  32. tests = 0
  33. testf = 0
  34. testc = 0
  35.  
  36. for i in range(0,100):
  37.     iv = '0000000000000000'
  38.     p = '1111111111111111'
  39.     e = Wszyfr.szyfrowanie(iv, p)
  40.     e = utils.tobits(e)
  41.     n = len(e)
  42.     if Serial.test(3, n, e) is True:
  43.         tests += 1
  44.     if Freq.test(e, 40, n) is True:
  45.         testf += 1
  46.     if CuSum.test(e, n, 0) is True:
  47.         testc += 1
  48.  
  49. print("Na 100 prob")
  50. print(
  51.     "Losowych ciagow wedlug test Serial: {} /Freq: {} /CuSum: {}".format(
  52.         tests, testf, testc
  53.     )
  54. )
  55.  
  56.  
  57. print("Zestaw 3")
  58.  
  59. tests = 0
  60. testf = 0
  61. testc = 0
  62. iv ='0000000000000000'
  63. p = '1111111111111111'
  64.  
  65. for i in range(0,100):
  66.     e = Wszyfr.szyfrowanie(iv,p)
  67.     e = utils.tobits(e)
  68.     n = len(e)
  69.     if Serial.test(3,n,e) is True:
  70.         tests += 1
  71.     if Freq.test(e, 40, n) is True:
  72.         testf += 1
  73.     if CuSum.test(e, n, 0) is True:
  74.         testc += 1
  75.     p =  utils.my_xor(p, '1111111111111111')
  76.  
  77. print("Na 100 prob")
  78. print(
  79.     "Losowych ciagow wedlug test Serial: {} /Freq: {} /CuSum: {}".format(
  80.         tests, testf, testc
  81.     )
  82. )
  83.  
  84.  
  85. print("Zestaw 4")
  86.  
  87. tests = 0
  88. testf = 0
  89. testc = 0
  90. iv = '1111111111111111'
  91. p = '0101010101010101'
  92.  
  93. for i in range(0, 100):
  94.     e = Wszyfr.szyfrowanie(iv,p)
  95.     e = utils.tobits(e)
  96.     n = len(e)
  97.     if Serial.test(3, n, e) is True:
  98.         tests += 1
  99.     if Freq.test(e, 40, n) is True:
  100.         testf += 1
  101.     if CuSum.test(e, n, 0) is True:
  102.         testc += 1
  103.     p = utils.my_xor(p, '1010101010101010')
  104.  
  105. print("Na 100 prob")
  106. print(
  107.     "Losowych ciagow wedlug test Serial: {} /Freq: {} /CuSum: {}".format(
  108.         tests, testf, testc
  109.     )
  110. )
  111.  
  112.  
  113. print("Zestaw 5")
  114.  
  115. tests = 0
  116. testf = 0
  117. testc = 0
  118. iv = '1111111111111111'
  119.  
  120. for i in range(0, 100):
  121.     if i%4 == 0:
  122.         p='1111111111111111'
  123.     if i%4 == 1:
  124.         p='0000000000000000'
  125.     if i%4 == 2:
  126.         p='0101010101010101'
  127.     if i%4 == 3:
  128.         p='1010101010101010'
  129.     e = Wszyfr.szyfrowanie(iv, p)
  130.     e = utils.tobits(e)
  131.     n = len(e)
  132.     if Serial.test(3, n, e) is True:
  133.         tests += 1
  134.     if Freq.test(e, 40, n) is True:
  135.         testf += 1
  136.     if CuSum.test(e, n, 0) is True:
  137.         testc += 1
  138.  
  139. print("Na 100 prob")
  140. print(
  141.     "Losowych ciagow wedlug test Serial: {} /Freq: {} /CuSum: {}".format(
  142.         tests, testf, testc
  143.     )
  144. )
  145.  
  146.  
  147. print("Zestaw 6")
  148.  
  149. tests = 0
  150. testf = 0
  151. testc = 0
  152. iv = '1111111111111111'
  153. pp = []
  154. pp.append('0010010010010010')
  155. p1 = '0010010010010010'
  156. p2 = '0110110110110110'
  157. p3 = '1111111111111111'
  158.  
  159. for i in range(0, 35):
  160.     pp.append(utils.my_xor(p1, pp[1+3 * i-1]))
  161.     pp.append(utils.my_xor(p2, pp[2+3 * i-1]))
  162.     pp.append(utils.my_xor(p3, pp[3+3 * i-1]))
  163.  
  164. for i in range(0, 100):
  165.     e = Wszyfr.szyfrowanie(iv,pp[i])
  166.     e = utils.tobits(e)
  167.     n = len(e)
  168.     if Serial.test(3, n, e) is True:
  169.         tests += 1
  170.     if Freq.test(e, 40, n) is True:
  171.         testf += 1
  172.     if CuSum.test(e, n, 0) is True:
  173.         testc += 1
  174.  
  175. print("Na 100 prob")
  176. print(
  177.     "Losowych ciagow wedlug test Serial: {} /Freq: {} /CuSum: {}".format(
  178.         tests, testf, testc
  179.     )
  180. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement