import
random
from
PIL
import
Image
from
Crypto.Util.number
import
long_to_bytes as n2b
random.seed(
793211
)
def
pbl(bits):
num
=
random.getrandbits(bits)
bins
=
[]
while
num:
bins.append(num &
1
)
num >>
=
1
while
len
(bins) !
=
bits:
bins.append(
0
)
return
bins
cat
=
Image.
open
(
'1.png'
)
cat1
=
Image.new(
'L'
, cat.size)
cat2
=
Image.new(
'L'
, cat.size)
cat3
=
Image.new(
'L'
, cat.size)
xcat
=
Image.
open
(
'xx.png'
)
xcat1
=
Image.new(
'L'
, cat.size)
xcat2
=
Image.new(
'L'
, cat.size)
xcat3
=
Image.new(
'L'
, cat.size)
x, y
=
cat.size
bits
=
x
*
y
r1, r2
=
pbl(bits), pbl(bits)
r3
=
[
0
]
*
((x
-
1
)
*
y
+
y )
for
i
in
range
(x):
for
j
in
range
(y):
pix
=
cat.getpixel((i, j))
xpix
=
xcat.getpixel((i,j))
r3[i
*
y
+
j]
=
pix[
2
] ^ xpix[
2
]
a
=
n2b(random.getrandbits((bits
-
28
)
*
8
))
gg
=
[i
for
i
in
range
(
27918
)]
random.shuffle(gg)
result
=
[i
for
_, i
in
sorted
(
zip
(gg,r3))]
fin
=
""
i
=
0
while
result[i] !
=
125
:
fin
=
fin
+
chr
(result[i])
i
=
i
+
1
print
(fin
+
'}'
)