I am writing an implementation of the XXTEA encryption algorithm that works on "threads", i.e. can be used as: crypt mykey <myfile>.
One of the details is that he does not have access to the file at all (he only reads a block of a fixed size until he finds EOF). The algorithm requires that the data bytes be a multiple of 4, so it was necessary to add indentation.
For plain text, laying with NULL is a good solution, and NULL is simply ignored in decryption, but the same strategy cannot be used for binary streams (which may contain embedded NULLs).
I read general solutions, such as padding with the number of missing characters (if it missed 3 characters, then add 3, 3, 3 at the end), etc., but I wonder: a more elegant solution
source
share