Code example for SecretKeySpec

  private Cipher getCipher(byte[] messageBytes)
      throws InvalidEncryptedSignalException, InvalidKeyException, 
             InvalidAlgorithmParameterException, NoSuchAlgorithmException, 
             NoSuchPaddingException, IOException 
    SecretKeySpec cipherKey = new SecretKeySpec(getCipherKey(), "AES");
    byte[] ivBytes          = new byte[16];
    if (messageBytes.length < ivBytes.length)
      throw new InvalidEncryptedSignalException("Message shorter than IV length."); 
    System.arraycopy(messageBytes, IV_OFFSET, ivBytes, 0, ivBytes.length);
    Cipher cipher      = Cipher.getInstance("AES/CBC/PKCS5Padding");
    IvParameterSpec iv = new IvParameterSpec(ivBytes);
    cipher.init(Cipher.DECRYPT_MODE, cipherKey, iv);
    return cipher;
Connect your IDE to all the code out there  Get Codota for Java