Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- N=32
- $ifdef= :binary
- 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]
- 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]
- 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]
- def rp(a)
- # time_t t;
- #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]
- #srand(clock()+time(&t));
- random=Random.new()
- for i in 0.. N-1
- a[i] = i
- end
- for i in 0..N-3
- # rand from i+1 to N-1
- j = (random.rand(0..256) % (N - 1 - i)) + i + 1
- # swap a[i] and a[j]
- x = a[j]
- a[j] = a[i]
- a[i] = x
- end
- if (a[N - 1] == N - 1)
- a[N - 1] = a[N - 2]
- a[N - 2] = N - 1
- end
- # return a
- end
- 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]
- 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]
- #binary version
- if $ifdef==:byte
- 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]
- elsif $ifdef==:binary
- b=[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]
- end
- for i in 1..32
- print b[i]
- end
- rp(x0)
- rp(x1)
- print x0
- print x1
- for i in 0..N-1
- x2[x0[i]]=i
- end
- j=0
- #byte version
- if $ifdef==:byte
- random2=Random.new()
- for i in 0..N-1
- b[i]=random2.rand(0..256)
- end
- end
- file=open("rand.dat","wb")
- while(j<10000000)
- for i in 0..N-1
- ww[i]=b[x1[i]]
- end
- for i in 0..N-1
- b[i]=b[i]^ww[i]
- end
- if $ifdef==:binary
- aa=0
- for k in 0..3
- for i in k*8..k*8+8-1
- aa=aa<<1
- aa=aa^b[i]
- end
- end
- file.write [aa].pack "i*"
- elsif $ifdef==:byte
- file.write b.pack("C*")
- end
- for i in 0..N-1
- w[i]=x0[x1[x2[i]]]
- end
- for i in 0..N-1
- x1[i]=w[i]
- end
- j=j+1
- end
- file.close
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement