Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. N=32
  2. x0=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
  3. x1=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
  4. x2=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
  5.  
  6.  
  7. def rp(a)
  8. # time_t t;
  9. #a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
  10. #srand(clock()+time(&t));
  11. random=Random.new()
  12.  
  13. for i in 0.. N-1
  14. a[i] = i
  15. end
  16. for i in 0..N-3
  17. # rand from i+1 to N-1
  18. j = (random.rand(0..256) % (N - 1 - i)) + i + 1
  19.  
  20. # swap a[i] and a[j]
  21. x = a[j]
  22. a[j] = a[i]
  23. a[i] = x
  24. end
  25. if (a[N - 1] == N - 1)
  26. a[N - 1] = a[N - 2]
  27. a[N - 2] = N - 1
  28. end
  29.  
  30. return a
  31.  
  32. end
  33. w=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
  34. ww=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
  35. b=[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
  36. for i in 1..32
  37. print b[i]
  38. end
  39. print rp(x0)
  40. print rp(x1)
  41. for i in 0..N-1
  42. x2[x0[i]]=i
  43. end
  44. j=0
  45. file=open("rand.dat","wb")
  46.  
  47. while(j<10000)
  48. for i in 0..N-1
  49. ww[i]=b[x1[i]]
  50. end
  51. for i in 0..N-1
  52. b[i]=b[i]^ww[i]
  53. end
  54. aa=0
  55. for k in 0..3
  56. for i in k*8..k*8+8-1
  57. aa=aa<<1
  58. aa=aa^b[i]
  59. end
  60. end
  61. file.write(aa)
  62. for i in 0..N-1
  63. w[i]=x0[x1[x2[i]]]
  64. end
  65. for i in 0..N-1
  66. x1[i]=w[i]
  67. end
  68. j=j+1
  69. end
  70. file.close
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement