muthu vel
muthu vel

Reputation: 119

Java DES encryption with random padding

I have a requirement to encrypt and decrypt a file using DES algorithm in java, I need to pad some random charatcters in between the file words during encryption and I need to remove them during decryption using program, so that even if somebody gets the secret key and encryted file , they will not be able to get the content, without using my program,is there any way available. to achieve this.

would appreciate your suggestions.

Upvotes: 0

Views: 559

Answers (1)

rossum
rossum

Reputation: 15693

Random padding can only be removed if the length of either the file, or the padding, is known.

You will have to ensure that one or the other is known to whoever decrypts the file, and hidden from all others. This is far from trivial. It is also not needed, since you will have to keep the key secret anyway, so adding a length just makes for extra work. Use PKCS7 for padding, and concentrate your efforts on keeping the key secret.

Upvotes: 2

Related Questions