You don't specify the mode and padding for the cipher in the call to getInstance()
, so the provider will choose default parameters. Your provider is defaulting to "PKCS5Padding", so it add 8 bytes with a value of 0x08 to your plain text before performing the DES encryption.
To avoid platform-dependent behavior, it's very important to specify a complete transformation when creating a Cipher
instance: algorithm, mode, and padding. If you don't want padding, say so:
Cipher ciph = Cipher.getInstance("DES/ECB/NoPadding");
SecretKey blah = new SecretKeySpec(key, "DES");
Why did you pad your key? Why wasn't your key 8 bytes long to start? If the first 7 bytes are intended to be used as the actual key, and lack parity bits, you can't just slap a byte on the end; you need to expand the key to eight bytes, appending one parity bit to each 7-bit chunk.
If you use the parity-adjusted key, 3EDCD613A754513B
, and no padding, the cipher text is C094C47D7F89E219
. Is that what you are expecting?