@WiNDfaLLx/

yeetle pateetle

Python

sECRET encOdeR

fork
loading
Files
  • main.py
  • alien cat.png
  • cover.jpg
  • hep me.png
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from PIL import Image

#to use: upload a 200x200 picture
#it can only use white, black, red, green, blue, cyan, magenta and yellow (pure/255 values)

cover = Image.open("alien cat.png").convert("RGB")
secret = Image.open("cover.jpg").convert("RGB")

out = Image.new("RGB", (200, 200))

makes_last_bit_zero = 254 #binary: 11111110
shift_amt = 7

for x in range(200):
  for y in range(200):
    secret_pix = secret.getpixel((x, y))
    public_pix = cover.getpixel((x, y))

    secret_red = secret_pix[0] >> shift_amt
    secret_green = secret_pix[1] >> shift_amt
    secret_blue = secret_pix[2] >> shift_amt
    #gets the first binary bit, so 128 and above is 1

    cover_red = public_pix[0] & makes_last_bit_zero
    cover_green = public_pix[1] & makes_last_bit_zero
    cover_blue = public_pix[2] & makes_last_bit_zero
    #& does an AND operation for every bit in the number
    
    final = (
      secret_red + cover_red,
      secret_green + cover_green,
      secret_blue + cover_blue
    )
    #so it puts the last bit as a secret value!!!

    out.putpixel((x, y), final)

# must be png! no jpg because compression is evil :(
out.save('out.png')