3
$\begingroup$

You are given three files.

One is a snippet from scrambler.py file:

from PIL import Image
from random import randint

if input("[E]ncoding or [D]ecoding?\n(default: decoding)\n") == "E":
    encode = True
    print("ENCODING: ")
else:
    encode = False
    print("DECODING: ")

if encode:
    file = Image.open(input("Image to scramble: "))
    pix = file.load()
    keyfile = open("scrambled.txt", "w")

    for x in range(file.size[0]):
        for y in range(file.size[1]):
            temp = pix[x, y]
            newx = randint(0, file.size[0] - 1)
            newy = randint(0, file.size[1] - 1)
            pix[x, y] = pix[newx, newy]
            pix[newx, newy] = temp
            keyfile.write(str(x * 7) + " " + str(y * 14) + " " + str(newx * 5) + " " + str(newy * 6) + "\n")
    file.show()

The second is a file called scrambled.txt.

The final is an image called scrambled.png:

scrambled.png


Who left this message for you?


Note: Gareth! Give the people a chance, please!

$\endgroup$
5
$\begingroup$

Trivially-reversible permutation

$\endgroup$
  • $\begingroup$ Why are all the colors distorted? $\endgroup$ – Voldemort's Wrath Oct 31 at 20:14
  • 4
    $\begingroup$ @Voldemort'sWrath Probably because the image in the question was uploaded as a JPG, not a PNG (imgur automatically converts images above a certain size to JPG). $\endgroup$ – 2012rcampion Nov 1 at 0:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.