What is the most efficient method / cryptography provider for encrypting strings which results in the shortest possible string. Our goal is that we have to encrypt a string and we want to achieve the shortest possible string after encryption.
So far we have tested with Tripple DES and Rijndael and both resulted in exactly the same encrypted length. I have also played around with longer and shorter key sizes but that also did not make much difference.
I’m not much of an expert on cryptography so I don’t know if there is perhaps some mathematical reason or explanation why a string of length y can only be encrypted to length x – hoping to hear from your expert opinions.
How long are your strings? Very long strings can be compressed before encryption.
To produce a cyphertext the same length as the plaintext you can:
use a stream cypher such as RC4, or one of the eSTREAM cyphers
use a block cypher (e.g. AES) in CTR mode.
If your strings are all exactly 8 bytes or all 16 bytes, then you could use a block cypher with the appropriate block size in ECB mode and no padding.