gchq / CyberChef

The Cyber Swiss Army Knife - a web app for encryption, encoding, compression and data analysis

Home Page:https://gchq.github.io/CyberChef

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug report: Substitution does not work with UTF-8 encoded characters

LukeSerne opened this issue · comments

Describe the bug
The "Substitute" operation does not interpret UTF-8 encoded strings properly. It doesn't work properly when any of the plaintext alphabet, the ciphertext alphabet or the input contains UTF-8 encoded strings.

To Reproduce

  1. Go to this link
  2. See that the output is not the expected 01010101, but instead contains a warning and 01⚽01⚽01⚽01⚽.

Expected behaviour
The output should be 01010101.

Additional context
From a quick look at the source code, it seems there are two causes of this behaviour.

  1. The way the input is iterated over (using a for-loop up to input.length).
  2. The way the plaintext and ciphertext are transformed using Utils.expandAlphRange.