javaencryptionaesecbblock-cipher

Java: Which mode is by default set in Javax Cipher class?


I am working on securing a chat application written in Java (it is downloaded from the internet, and now I want to secure it in order to learn). I have read the documentation, but I am unable to figure out which mode of encryption is set by default, if I don't explicitly put one. Is it ECB? If so, what's the key differences between it and other modes of encryption in regards of a chat application? It's worth mentioning that I watched this explanation before posting here as I still couldn't figure out the answers to my questions.

The way I have encrypted/decrypted the messages transmitted is by:

I would say this is ECB.

I hope somebody can clarify it for me!


Solution

  • In the document you linked to, there is an example: Cipher c = Cipher.getInstance("AES/CBC/PKCS5Padding") it uses CBC mode. The same document lists ECB as a valid mode for AES.

    You will have to spell out the mode yourself.