I am encrypting a string with AES in Java Netbeans using
Key aesKey = new SecretKeySpec(key.getBytes(), "AES");
Cipher cipher = Cipher.getInstance("AES");
// encrypt the text
cipher.init(Cipher.ENCRYPT_MODE, aesKey);
byte[] encrypted = cipher.doFinal(text.getBytes());
System.err.println(new String(encrypted));
The result I am getting are special characters. If I encrypt the text "1111" with a 128 bit key "Bar12345Bar12345" then I am getting the output as []3SU[][][]~a[][]`)
Is this valid? If not what should be the output then and how can i get the correct output?