1
$\begingroup$

As we know, the index table (which maps bytes in [0, 63] to characters) of Base64 encoding is public, so everyone can decode Base64 strings from others.

But what if we use a shuffled index table and keep it secret? Can we see Base64 with this new table as some sort of safe encryption, and the shuffled table as cipher?

$\endgroup$
  • $\begingroup$ Did you see permutation cipher? Some sort of frequency attack will be possible. But there is no security against known plaintext attack. $\endgroup$ – kelalaka Dec 2 '18 at 17:04
  • 1
    $\begingroup$ @kelalaka actually this is a substitution cipher as the ciphertext is not an anagram of the plaintext. $\endgroup$ – SEJPM Dec 2 '18 at 19:13
  • $\begingroup$ @SEJPM yes, the correct term, thanks. Modulo 24-bit, the conversion bits (6 vs 8) fits. If we arrange the ciphertext column-wise, the frequency attack must be still working. $\endgroup$ – kelalaka Dec 2 '18 at 19:19
  • $\begingroup$ See also crypto.stackexchange.com/questions/62425/… $\endgroup$ – Ilmari Karonen Dec 4 '18 at 15:15
5
$\begingroup$

Can we see Base64 with this new table as some sort of [..] encryption [...]?

Yes, technically it does constitute a form of encryption as knowledge of a secret key is required to recover plaintext from ciphertext.

Can we see Base64 with this new table as some sort of safe encryption [...]?

NO! This is essentially a monoalphabetic substitution cipher applied on the Base64 encoded data. This can be seen as you can always take your table $T$ and then find a new $T'$ that undoes the base64 table encoding first and then applied after standard Base64 encoding.

Now while the key size is (theoretically) respectable with $\log_2 (64!)\approx 296$ bit, this cipher suffers from all the usual problems such ciphers have, including:

  • Ciphertext-only attacks are possible using frequency analysis, as there are only 64 valid plaintext values and they will probably occur with different frequencies.
  • Known- and chosen plaintext attacks are devastating as there are only 64 mappings to be uncovered and usually plaintexts have quite a bit of structure allowing to guess the rest / uncover significant parts of the plaintext.
| improve this answer | |
$\endgroup$

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.