I am implementing DES - CBC. I am confused as to what cipher.init, cipher.update and cipher.dofinal do. I just use init to set the key and dofinal to get the result. I don't use update. Is that correct?
Also whats the difference to the result when using UTF-8 and ASCII encodings?
Here is my code:
byte[] ciphertext;
Cipher enc = Cipher.getInstance("DES/CBC/PKCS5Padding");
enc.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, "DES"), new IvParameterSpec(vector));
// Is this the complete ciphertext?
ciphertext = encrypt.doFinal(data.getbytes("UTF-8"));
byte, notbytes...Cipher? The javadocs should be helpful.