I just thought of a cipher, here's how it goes:

Input strkey intkey Output
Hello World! abc 9 ƉƦƭƭưšƘưƳƭƥŢ
Crack this cipher i'm happy 13 ŧʦƖ˕ƅ˄ƇˆƏˎńʃƘ˗ƌˋƍˌƗ˖ńʃƇˆƍˌƔ˓ƌˋƉˈƖ˕
POW! !@@#$^&*() 2 ɋɊɒȜ

Given the following input, what is the expected output, and why?

Input strkey intkey
Painting hello 19
Hints and Tips

Hint 1:

This involves Unicode, of course.

Hint 2:

Think about Caesar cipher.


I think the encoded "Painting" is:


How does the cipher work?

The cipher uses a constant offset to the plaintext's Unicode values. For example, the first message has an offset of 321 or 014116:

H e l l o w o r l d !
orig.: 0048 0065 006c 006c 006f 0020 0077 006f 0072 006c 0064 0021
offset: 0189 01a6 01ad 01ad 01b0 0161 0198 01b0 01b3 01ad 01a5 0162

The bottom line has the Unicode values of the ciphertext, ƉƦƭƭưšƘưƳƭƥŢ.

The constant offset is calculated by adding the Unicode values of the key offset by the integer key, in Python: offset = sum(ord(c) + intkey for c in strkey).

The offset for the third example is 507. The calculated offset fot the second example is 948, but there's something else going on, because each letter of the plaintext is encoded into two Unicode points with constant offsets of 292 and 611. (Many of these offsets yield combination characters that appear as diacritic marks.) We get those by calculating the offset separately for each of the words in the string key: "i'm" and "happy".

So the rule for encoding is:

Given a string key s, an integer key k and a plaintext p, you can get the ciphertext c as follows: Split s into n words wi. For each word, calulate an offset Δi by summing the Unicode values of each character offset by k. (The offset applies to each character; alternatively, sum the character codes, then add n·k.)

For each character of the plaintext p, add n characters offset by wi to the ciphertext c.

The last example ...

... has a single-word string key that yields the offset 627. Applying this offset to the plaintext "Painting" gives the Unicode characters shown above.

Puzzle critique:

The puzzle uses a simple encoding scheme and while it can be fun to work out how the cipher works, the puzzle also involves a lot of work getting at the Unicode values of the ciphertexts. The fact that some of these characters are combining characters doesn't make it easier.

The codes themselves are not very interesting, either. The ciphertext is just gibberish. I would have liked it better if the keys were chosen to make gibberish with only Greek or Cyrillic letters. You've the whole Unicode range to chose from. Why not pose a problem with a nice ciphertext so that someone who solves it can be confident that they solved it. A quick example:

encode(cipher = "rust", intkey = 2314, strkey = "foxy")

  • $\begingroup$ That was the intended answer. Congratulations! $\endgroup$
    – Alan Bagel
    Oct 7 at 12:23

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.