I encountered a problem. I am trying to encrypt a byte array with length 8. But the length of cipher I obtained is 16. How can I make this to be 8?
In the following code, temp length is 8, and out's length is 16.
Code: Select all
Cipher cipherinstance = Cipher.getInstance(Cipher.ALG_DES_CBC_ISO9797_M2, false);
DESKey deskey = (DESKey)KeyBuilder.buildKey(KeyBuilder.TYPE_DES, KeyBuilder.LENGTH_DES, false);
deskey.setKey(KEY_8_BYTES, (short)0);
out = cipherinstance.doFinal(temp, (short)0, (short)temp.length, res, (short)0);