Reputation: 5277
I'm using this code for DES encryption: How do I use 3des encryption/decryption in Java?
I'm encrypting byte array of size 8. As far as I know, it should result in encrypted data of size 8. But the result is 16 bytes.
I've done necessary edits in the code to do DES encryption of byte array. Like changed the algo name to DES (than DEDede), key size of 8 bytes (than 24) etc.
Upvotes: 0
Views: 669
Reputation: 61952
DES has a block size of 64 bit or 8 byte. Modes of operations like CBC and ECB are block based, but in order to encrypt plaintexts of arbitrary it is necessary to use a padding scheme like PKCS#5/PKCS#7 paddings to pad the arbitrary plaintext to the next multiple of the block size.
The padding itself contains the information how many bytes where added for PKCS#5 padding. Since 8 byte is already a multiple of the block size, a full padding block is added. It this weren't the case, you would be able to reliably disambiguate plaintext and padding after decryption.
Upvotes: 2