# Can you pick up an extra shift?

I was going through some old documents the other day and found some instructions for a one way cipher:

Given a word w, iterate over its characters. For each character c, determine if its zero based index in the alphabet is odd or even. Once determined, perform one of the following actions:

• Odd: Subtract two.

Replace the character c with this newly determined index. For example:

input = test
output = rftr


To confirm your results, performing the algorithm on the word azalea should yield the following output:

wsweaw

However, when I attempted to recreate the results, my answer was incorrect. Upon closer inspection, it appears there was a sentence between character replacement example and the confirmation, but it's so faded that I can't make it out.

Can you help me find the missing step?

• 7 hours and unsolved. That's serious. The cipher is indecipherable if taken at face value, because information is irreversibly lost on the surjective replacement step. The mystery step "between character replacement example and the confirmation” thus must access plaintext to recover the loss. Aug 10, 2021 at 5:33
• Oops. My previous comment about indecipherability may not possibly apply. I missed the wording “one way cipher” in the first paragraph, which is confusing. Taco-Takosu, could you please confirm that the problem asks for a hash, not a cipher in the pedantic sense (i.e. reversible encryption)? This Security.SO answer resolves a very similar confusion over terminology IRL. Aug 11, 2021 at 2:39
• @kkm it is technically a hash because it cannot be reversed. The reason it can’t be reversed is highlighted in the accepted answer. Aug 11, 2021 at 2:58
• Thanks! I'd rather say the reason it can't be reversed is the puzzle states so, however. Since the lost step has access to both the intermediate result and plaintext, the question might have reasonably asked for a reversible cipher (a proof that one exists is a trivially constructible 2D pad). Wondering if this same puzzle has an interesting solution for a reversible cipher case (where interesting is understood as "fit for Puzzling.SO"). :) Aug 11, 2021 at 3:16

So it looks like the missing step is to:

Subtract 5 from the numeric index resulting from the first new replacement step. So for example:

Plaintext: a
Has index: 0, which is even, so we
Add 1 to get 1, from which we subtract 5 (mod 26), to get
-4 = 22 (mod 26), which yields
Ciphertext: w

BUT!

This cipher cannot be decrypted. Notice that plaintext "d" also "encrypts" to "w", since d has numeric index 3, from which we subtract 2 to get 1. Then the rest of the encryption is the same. So perhaps the mystery shift is more complicated.