Saturday 15 September 2012

cryptography - What does cipher.update do in java? -



cryptography - What does cipher.update do in java? -

i implementing des - cbc. confused cipher.init, cipher.update , cipher.dofinal do. utilize init set key , dofinal result. don't utilize update. correct?

also whats difference result when using utf-8 , ascii encodings?

here code:

byte[] ciphertext; cipher enc = cipher.getinstance("des/cbc/pkcs5padding"); enc.init(cipher.encrypt_mode, new secretkeyspec(key, "des"), new ivparameterspec(vector)); // finish ciphertext? ciphertext = encrypt.dofinal(data.getbytes("utf-8"));

the javadoc cipher.dofinal(byte[]) says (in part emphasis added),

encrypts or decrypts info in single-part operation, or finishes multiple-part operation. info encrypted or decrypted, depending on how cipher initialized.

the bytes in input buffer, , input bytes may have been buffered during previous update operation, processed, padding (if requested) beingness applied. if aead mode such gcm/ccm beingness used, authentication tag appended in case of encryption, or verified in case of decryption. result stored in new buffer.

this done don't have read of file (for example) memory in order encrypt it.

java cryptography aes des cbc-mode

No comments:

Post a Comment