4
$\begingroup$

Is there a way to limit the output of AES-256 to only alphanumeric characters and maintain 256-bit key? I'm looking encrypting some data and use the encrypted data in a system, and the reason behind using Alphanumeric characters is that the system might have issues processing special characters.

$\endgroup$
15
$\begingroup$

The standard way to do this is known as "ASCII armoring".

The idea is that, on encryption, you have the crypto (AES in your case) generate the ciphertext in binary, and then you convert that binary into the character set that is appropriate to you; you can convert it into hexadecimal, you can encode it into Base64, or you can use a more aggressive encoding with a larger character set.

Then, on decryption, you would take the ciphertext you receive, and convert it back into binary, and then hand that back to your decrypt for the rest of the decryption.

This procedure does make the ciphertext longer; doubling the size of you use hexadecimal; 33% longer if you use Base64; somewhat less if you use a more aggressive encoding. However, it can be shown that this cannot weaken the cryptography.

$\endgroup$
  • $\begingroup$ It's the same idea as taking the cyphertext and sticking it in a zipfile; lossless containers have no more effect on it than a filesystem would. $\endgroup$ – StarWeaver Apr 13 '17 at 21: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.