static byte[] crypt(byte[] input, String key, String algorithm, byte[] ivOrSalt, int iterations, boolean doDecrypt) throws PageException {

	try {
	    return _crypt(input, key, algorithm, ivOrSalt, iterations, doDecrypt);
	}
	// this is an ugly patch but it looks lime that ACF simply double to short keys
	catch (PageException pe) {
	    String msg = pe.getMessage();
	    if (msg != null && key.length() == 4 && msg.indexOf(" 40 ") != -1 && msg.indexOf(" 1024 ") != -1) {
		return _crypt(input, key + key, algorithm, ivOrSalt, iterations, doDecrypt);
	    }
	    if (msg != null && key.length() > 4 && key.length() % 4 == 0 && msg.indexOf("Illegal key size") != -1) {
		return crypt(input, key.substring(0, key.length() - 4), algorithm, ivOrSalt, iterations, doDecrypt);
	    }
	    throw pe;
	}
    }
static byte [ ] crypt ( byte [ ] input , String key , String algorithm , byte [ ] ivOrSalt , int iterations , boolean doDecrypt ) throws PageException { try { return _crypt ( input , key , algorithm , ivOrSalt , iterations , doDecrypt ) ; } catch ( PageException pe ) { String msg = pe . getMessage ( ) ; if ( msg != null && key . length ( ) == 4 && msg . indexOf ( " 40 " ) != - 1 && msg . indexOf ( " 1024 " ) != - 1 ) { return _crypt ( input , key + key , algorithm , ivOrSalt , iterations , doDecrypt ) ; } if ( msg != null && key . length ( ) > 4 && key . length ( ) % 4 == 0 && msg . indexOf ( "Illegal key size" ) != - 1 ) { return crypt ( input , key . substring ( 0 , key . length ( ) - 4 ) , algorithm , ivOrSalt , iterations , doDecrypt ) ; } throw pe ; } }
@param input - the clear-text input to be encrypted, or the encrypted input to be decrypted
@param key - the encryption key
@param algorithm - algorithm in JCE scheme
@param ivOrSalt - Initialization Vector for algorithms with Feedback Mode that is not ECB, or
Salt for Password Based Encryption algorithms
@param iterations - number of Iterations for Password Based Encryption algorithms (recommended
minimum value is 1000)
@param doDecrypt - the Operation Type, pass false for Encrypt or true for Decrypt
@return
@throws PageException