Articles, Blog

racket encryption video 4/4 — image encryption

February 11, 2020

Here’s Doctor Racket. The language is the racket language, the language specified
at source. We’re going to use definitions from obscure.rkt to obscure intensities,
plus some image tools, plus some color utilities. That’s how we “require” them.
We’re also going to want an elephant called jumbo, so we’ll define one. Let’s first scrambled the red part of
jumbo… here’s how we do it. For each color in jumbo we bind the name old to it… Then we change the redness of old, by obscuring its intensity,
basically multiplying its intensity by 31, and then taking the remainder modulo 257. Once it’s scrambled, it’s starting to look a little strange… Let’s scramble the blue part. So, I define a name scrambled-blue, I
start out from the scrambled-red version… bind old to each color in scrambled-red
in turn, and now I’m going to change the blue in each of those. So I’m gonna make the blue the previous blue multiplied by 31, take the remainder
modulo 257 to see what that does. Starting to look a bit strange-er… Finally I scramble the green color. I start out from scrambled-blue and I set the green of each color to be the previous version of the green multiplied by 31, and so on. That’s really scrambled — no elephants there!
Let’s try unscrambling these in a different order. I’ll first unscramble the blue part. I start with the scrambled green version,
completely elephant-less, and I’m going to change the blue
intensity. Start out with the blue in the scrambled version, only
the magic number 199 is used — look at abstraction, racket extraction, for why
199 is useful. An elephant is dimly reappearing
here. I’m going to unscramble the red parts, so I
start with the unscrambled blue version, and I’m gonna work on just the red
colors, so I change each old red by multiplying it by 199 and
taking the remainder… Definitely a bit more elephant-like. How about if I unscramble the green… Now the green colors are going to be the scrambled-green colors, but multiplied by 199 which we
hope will restore them… Drum roll please… got jumbo back! Jumbo’s been through a lot, let’s look at all of the somewhat psychedelic versions of jumbo
side by side, just to see you at this poor elephant
has endured. There you have it.


  • Reply MrValiantrobe April 12, 2013 at 11:55 pm

    Thank you for the free learning material. I'm very new to programming so this is my first language, but I was wondering how or where to save previous rkt files so I can call on them later.

    In the example here I need to call on obscure.rkt but it can't find the file. Is there a specific folder in Racket I should be saving these to?

  • Reply MrValiantrobe April 13, 2013 at 12:11 am

    It was a simple case of misspelling the file name, thanks again for these helpful videos!

  • Reply Danny Heap April 15, 2013 at 11:06 pm

    I saved mine to the current folder, or occasionally a folder I called Scratch.

  • Reply Danny Heap April 15, 2013 at 11:07 pm

    Did it work?

  • Leave a Reply