Today I found out that when I am using encryption in a way like it is implemented in this example, BadPaddingException can appear when encrypted message is too short - like "test" but is working fine with messages which are like 20 characters long