I’ve developed a Python program that performs format-preserving encryption (FPE) for all data types, including numeric, alphanumeric, and alphabetic. It ensures that the data type (alpha or numeric) and the case (upper or lower) are preserved. For example, “Hdcj213” might be encrypted as something like “Bcdg980.”
The challenge I’m facing is with data that falls below the minimum length required for FF3 (the FPE algorithm). For numeric data, the minimum length is 6 digits, so I can’t encrypt and preserve the format of something like “492.” For alphabetic data, the minimum is 4 characters.
Padding is not a viable solution because it disrupts the format, and the goal is to preserve the format after encryption.
Is there a solution for handling short plaintexts?