It depends on the encryption algorithm, mode and block size.
For example AES uses a fixed block size of 128 bits (16 bytes), CBC and ECB modes will return a fixed length, this length would be a multiple of 128.
If you use ECB mode and your input byte array length is 10 then you must add 6 bytes of padding in order to complete the block.
There are many ways to pad the block, you can use PKCS5 or PKCS7.
In java you can use Bouncy Castle's library https://www.bouncycastle.org/
Make sure you use a secure IV and derived encryption key
In the following example padding is handled by the library
public byte[] genIV() {
byte[] iv = new byte[16];
new SecureRandom().nextBytes(iv);
return iv;
}
public byte[] encrypt(byte[] plaintext, byte[] secretKey, byte[] iv) throws NoSuchPaddingException, NoSuchAlgorithmException, NoSuchProviderException, BadPaddingException, IllegalBlockSizeException, InvalidAlgorithmParameterException, InvalidKeyException {
Cipher in = Cipher.getInstance("AES/ECB/PKCS5Padding", "BC");
Key key = new SecretKeySpec(secretKey, "AES");
in.init(Cipher.ENCRYPT_MODE, key, new IvParameterSpec(iv));
return in.doFinal(plaintext);
}
public byte[] decrypt(byte[] ciphertext, byte[] secretKey, byte[] iv) throws InvalidAlgorithmParameterException, InvalidKeyException, NoSuchPaddingException, NoSuchAlgorithmException, NoSuchProviderException, BadPaddingException, IllegalBlockSizeException {
Key key = new SecretKeySpec(secretKey, "AES");
Cipher out = Cipher.getInstance("AES/ECB/PKCS5Padding", "BC");
out.init(Cipher.DECRYPT_MODE, key, new IvParameterSpec(iv));
return out.doFinal(ciphertext);
}
Bear in mind that each character in a String, depending on the charset, is at least 8 bits long, in your example "abcdef" is at least 6 bytes long