2

I am trying to encrypt few database columns (string values) using Java AES algorithm. This is to protect certain sensitive data. For some users these data should decrypted.

In Java AES encryption, if my input character length is 60, I am getting encrypted string length as 88.

But I don't want a change the length of the encrypted data. We have huge amount to tables and many applications are using those tables. We want to minimize the impact of encrypting certain fields in the tables.

Is there is any recommended solution? OR is there is any recommended algorithm, code sample, etc?

1 Answer 1

1

In such situation you can use a stream cipher instead of a block cipher. Note that block ciphers can also be used as stream ciphers, for example the AES in counter mode.

If you have to use a block cipher and all your fields are larger than one block you can use cipher text stealing.

Both methods give you an output that has the same length as the input when regarded as byte array. There may be difficulties to represent the output byte array as a string in the same length as the input.

Sign up to request clarification or add additional context in comments.

1 Comment

Can you give an example code for this? I want the output string to me of same length - because we don't want to change the database column. This will impact many different applications

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.