My problem is the following:
In an existing database I want to encrypt data in a couple of columns. The columns contains strings of different lengths.
I don't want to change the size of the columns so the encryption need to produce an equal length text representation of the input text.
The strength of the encryption algorithm is of secondary interest but of course I want it to be as strong as it can be. Otherwise I wouldn't need to encrypt the data. But the most important thing is the size of the output.
Is this possible? If so how would I do it?
I'm interested in doing it in .NET. No database-level encryption.
If you want a longer ciphertext, just pad with zeroes. You can make the ciphertext as long as you want that way.
Given a string s, the task is to encrypt the string in the following way: If the frequency of current character is even, then increment current character by x. If the frequency of current character is odd, then decrement current character by x.
One key encrypts data and another key decrypts it. Symmetric encryption uses the same key to perform both encryption and decryption functions. Symmetric encryption uses a shared private key while asymmetric encryption uses a public/private key pair.
Yes, with most operating modes of AES, the length of the encrypted string is the same regardless of key size (128, 192 or 256 bits). That's because AES-128, AES-192 and AES-256 all are 128-bit block ciphers, meaning they operate on 128-bit data blocks, regardless of key size.
Within your constrants, I would use AES in CFB mode, which turns it into a stream cipher and the output length will be the same as the input length. Unless you're storing the strings in blobs, you'll need to hex or base64 encode the output to make it char friendly, which will be a 100% or 33% increase in length.
One .NET implementation is here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With