private static byte[] crypto(byte[] message, String keyString, int cipherMode, IvParameterSpec ivps)
            throws GeneralSecurityException {
        String pair[] = keyString.split("\\s+");
        if (pair.length != 2 || !pair[1].matches("^[A-Za-z0-9+/=]+$")) {
            throw new InvalidKeyException("keyString should be of format: 'ALG base64key'");
        }
        byte[] raw = EncodingTool.base64Decode(pair[1]);
        String[] alg = pair[0].split("/");
        SecretKeySpec skeySpec = new SecretKeySpec(raw, alg[0]);
        Cipher cipher = Cipher.getInstance(pair[0]);
        if (alg.length == 1 || pair[0].contains("ECB")) {
            cipher.init(cipherMode, skeySpec);
        } else {
            cipher.init(cipherMode, skeySpec, ivps);
        }
        return cipher.doFinal(message);
    }