12
$\begingroup$

I have encoded a message, but I forgot how I encoded it! I drew a diagram, but I'm not sure I understand it...

Here's the message:

170, 358, 247, 137, 289, 175, 333, 233, 116, 263, 166, 305, 200, 344, 234, 119

And here's the diagram:

A description of how the cipher works

Hint:

Think: hexadecimal...

New contributor
Laszlo Pav is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
$\endgroup$
2
  • $\begingroup$ Welcome to Puzzling! Very nice first puzzle :) $\endgroup$ Commented yesterday
  • $\begingroup$ Thanks, @BeastlyGerbil! $\endgroup$ Commented yesterday

2 Answers 2

11
$\begingroup$

The message is

Congradulations!

(Note the 'd' instead of 't' seems intentional, perhaps a pun!)

How it works:

The first number given is 170, which is 'AA' in hexadecimal.

Now we already have an 'AA' given in the chart, so this is our starting point! This also means this is a rolling decryption.

So, following the chart, if the square represents '$C_i$', our current character number in ASCII, and the blue 'c' represents '$C_{i-1}$', our previous number, then we can see we we have $C_i + (FF-C_{i-1})$ in the middle.

'AA' is fed in at the start to give the first value, and then everything is fed into $\text{mod}\ FF$ at the bottom. Rearranging and inverting to reverse the process, we can find the characters using the formula:
$$FF - ( (C_i-(C_{i-1}\ \text{mod}\ FF))\ \text{mod}\ FF)$$ We can convert all of this to base 10 by noting 'FF' is 255, so we are working in mod 255.

So lets decrypt!

Starting with 170, our next number is 358:

1. $255 - (358-(170\ \text{mod}\ 255)\ \text{mod}\ 255) = 255 - 188 = 67$
2. $255 - (247-(358\ \text{mod}\ 255)\ \text{mod}\ 255) = 255 - 144 = 111$
3. $255 - (137-(247\ \text{mod}\ 255)\ \text{mod}\ 255) = 255 - 145 = 110$
4. $255 - (289-(137\ \text{mod}\ 255)\ \text{mod}\ 255) = 255 - 152 = 103$
5. $255 - (175-(289\ \text{mod}\ 255)\ \text{mod}\ 255) = 255 - 141 = 114$
6. $255 - (333-(175\ \text{mod}\ 255)\ \text{mod}\ 255) = 255 - 158 = 97$
7. $255 - (233-(333\ \text{mod}\ 255)\ \text{mod}\ 255) = 255 - 155 = 100$
8. $255 - (116-(233\ \text{mod}\ 255)\ \text{mod}\ 255) = 255 - 138 = 117$
9. $255 - (263-(116\ \text{mod}\ 255)\ \text{mod}\ 255) = 255 - 147 = 108$
10. $255 - (166-(263\ \text{mod}\ 255)\ \text{mod}\ 255) = 255 - 158 = 97$
11. $255 - (305-(166\ \text{mod}\ 255)\ \text{mod}\ 255) = 255 - 139 = 116$
12. $255 - (200-(305\ \text{mod}\ 255)\ \text{mod}\ 255) = 255 - 150 = 105$
13. $255 - (344-(200\ \text{mod}\ 255)\ \text{mod}\ 255) = 255 - 144 = 111$
14. $255 - (234-(344\ \text{mod}\ 255)\ \text{mod}\ 255) = 255 - 145 = 110$
15. $255 - (119-(234\ \text{mod}\ 255)\ \text{mod}\ 255) = 255 - 140 = 115$

So now we have the new string of numbers

$67,111,110,103,114,97,100,117,108,97,116,105,111,110,115$

Which we can decode

Back into text via ASCII to get the final answer:

'Congradulations'!

$\endgroup$
7
  • $\begingroup$ Oops!! That was not a pun... $\endgroup$ Commented yesterday
  • $\begingroup$ @LaszloPav whoops... oh well, just say its a feature, not a bug :P $\endgroup$ Commented yesterday
  • $\begingroup$ The formula simplifies to reveal spoiler (old - new) mod 255 $\endgroup$ Commented yesterday
  • $\begingroup$ @n1000 good point, I didn't even consider simplifying as wanted to just convert the chart to a formula, but that's much easier in hindsight $\endgroup$ Commented yesterday
  • 1
    $\begingroup$ Will you please explain how you got that formula from the diagram? And something is off with the parenthesis, 3 open and 2 closed. And what are the square brackets? $\endgroup$ Commented yesterday
0
$\begingroup$

Some thoughts on how to interpret the diagram:

  • With the hint, it is evident that that AA and FF represent hexadecimal numbers 0xAA = 170 and 0xFF = 255 respectively.
  • The cyclic nature of the diagram suggests that there is a loop of some sort, and it seems plausible to assume that AA is the initial seed value used for this loop.

With the above assumptions in mind, one can read off the encoding operations as:

$$\boxed{\begin{aligned} d_0 &= \texttt{0xAA} \\ d_i &= d_{i - 1} + (\texttt{0xFF} - c_i) \\ e_i &= c_i + (d_i \bmod \texttt{0xFF}) \end{aligned}}$$ where

  • $c_i$ is the original, un-encoded character,
  • $d_i$ is the loop state, carried from one iteration to the next, and
  • $e_i$ is the encoded character.

With the encoding algorithm documented, the next step is to figure out how to reverse it into a decoding algorithm:

A crucial observation is that $e_i$ contains both a $c_i$ term and a $(\cdots - c_i) \bmod \mathtt{0xFF}$ term: $$\begin{aligned} e_i &= c_i + (d_i \bmod \texttt{0xFF}) \\ &= c_i + ((d_{i - 1} + \texttt{0xFF} - c_i) \bmod \texttt{0xFF}) \end{aligned}$$ By applying $\bmod \mathtt{0xFF}$ to both sides, the $c_i$ term can be eliminated using the properties of modulo: $$\begin{aligned} e_i \bmod \mathtt{0xFF} &= (c_i + ((d_{i - 1} + \texttt{0xFF} - c_i) \bmod \texttt{0xFF})) \bmod \mathtt{0xFF} \\ &= (c_i + d_{i - 1} + \texttt{0xFF} - c_i) \bmod \mathtt{0xFF} \\ &= d_{i - 1} \bmod \mathtt{0xFF} \end{aligned}$$ Substituting $i \mapsto i + 1$: $$e_{i + 1} \bmod \mathtt{0xFF} = d_i \bmod \mathtt{0xFF}$$ This result can then be plugged back into the definition of $e_i$ and solved for $c_i$: $$\begin{aligned} e_i &= c_i + (d_i \bmod \texttt{0xFF}) \\ &= c_i + (e_{i + 1} \bmod \mathtt{0xFF}) \\ e_i - (e_{i + 1} \bmod \mathtt{0xFF}) &= c_i \end{aligned}$$ This yields the decoding algorithm: $$\boxed{c_i = e_i - (e_{i + 1} \bmod \mathtt{0xFF})}$$

With the decoding algorithm in hand, it can be applied to the encoded message to recover the original:

For example, the first character is given by: $$\begin{aligned} c_1 &= e_1 - (e_2 \bmod \mathtt{0xFF}) \\ &= 170 - (358 \bmod 255) \\ &= 170 - 103 \\ &= 67 \end{aligned}$$ One may guess that the original message was in ASCII format, so a numerical value such as 67 can be interpreted as the ASCII character C. The remaining characters can be decoded as follows:

 i   e[i]   c[i]  ASCII
 ----------------------
 1    170     67    C
 2    358    111    o
 3    247    110    n
 4    137    103    g
 5    289    114    r
 6    175     97    a
 7    333    100    d
 8    233    117    u
 9    116    108    l
10    263     97    a
11    166    116    t
12    305    105    i
13    200    111    o
14    344    110    n
15    234    115    s
      119

New contributor
Rufflewind is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
$\endgroup$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.