• API
• FAQ
• Tools
• Archive
daily pastebin goal
57%
SHARE
TWEET

# Untitled

a guest Mar 20th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. N=32
2. \$ifdef= :binary
3. 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]
4. 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]
5. 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]
6.
7.
8. def rp(a)
9.  #   time_t t;
10. #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]
11. #srand(clock()+time(&t));
12. random=Random.new()
13.
14.     for i in 0.. N-1
15.         a[i] = i
16.     end
17.     for i in 0..N-3
18.         # rand from i+1 to N-1
19.         j = (random.rand(0..256) % (N - 1 - i)) + i + 1
20.
21.         # swap a[i] and a[j]
22.         x = a[j]
23.         a[j] = a[i]
24.         a[i] = x
25.     end
26.     if (a[N - 1] == N - 1)
27.         a[N - 1] = a[N - 2]
28.         a[N - 2] = N - 1
29.     end
30.
31. #    return a
32.
33. end
34. 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]
35. 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]
36. #binary version
37. if \$ifdef==:byte
38. 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]
39. elsif \$ifdef==:binary
40.     b=[0,0,0,0,0,0,
41.     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]
42. end
43. for i in 1..32
44. print b[i]
45. end
46.  rp(x0)
47.  rp(x1)
48. print x0
49. print x1
50. for i in 0..N-1
51.     x2[x0[i]]=i
52. end
53. j=0
54. #byte version
55. if \$ifdef==:byte
56. random2=Random.new()
57. for i in 0..N-1
58.     b[i]=random2.rand(0..256)
59. end
60. end
61. file=open("rand.dat","wb")
62.
63. while(j<10000000)
64.     for i in 0..N-1
65.         ww[i]=b[x1[i]]
66.     end
67.     for i in 0..N-1
68.         b[i]=b[i]^ww[i]
69.     end
70. if \$ifdef==:binary
71.     aa=0
72.     for k in 0..3
73.         for i in k*8..k*8+8-1
74.             aa=aa<<1
75.             aa=aa^b[i]
76.         end
77.     end
78.     file.write [aa].pack "i*"
79. elsif \$ifdef==:byte
80.     file.write b.pack("C*")
81. end
82.     for i in 0..N-1
83.         w[i]=x0[x1[x2[i]]]
84.     end
85.     for i in 0..N-1
86.         x1[i]=w[i]
87.     end
88.     j=j+1
89. end
90. file.close
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top