@Override
    public String decrypt(String cryptoKey, String encrypted) throws TechnicalException {
        if (!encrypted.startsWith(getPrefix())) {
            logger.error(TechnicalException.TECHNICAL_ERROR_MESSAGE_DECRYPT_EXCEPTION);
            throw new TechnicalException(Messages.getMessage(TechnicalException.TECHNICAL_ERROR_MESSAGE_DECRYPT_EXCEPTION));
        }
        Key aesKey = null;
        if (cryptoKey != null && !"".equals(cryptoKey)) {
            aesKey = buildKey16char(cryptoKey);
        }
        if (aesKey == null) {
            logger.error(TechnicalException.TECHNICAL_ERROR_MESSAGE_DECRYPT_CONFIGURATION_EXCEPTION);
            throw new TechnicalException(Messages.getMessage(TechnicalException.TECHNICAL_ERROR_MESSAGE_DECRYPT_CONFIGURATION_EXCEPTION));
        }
        try {
            Cipher cipher = Cipher.getInstance("AES");
            cipher.init(Cipher.DECRYPT_MODE, aesKey);
            return new String(cipher.doFinal(Base64.decodeBase64(encrypted.substring(getPrefix().length(), encrypted.length()))));
        } catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | IllegalBlockSizeException | BadPaddingException e) {
            throw new TechnicalException(Messages.getMessage(TechnicalException.TECHNICAL_ERROR_MESSAGE_DECRYPT_EXCEPTION), e);
        }
    }
@ Override public String decrypt ( String cryptoKey , String encrypted ) throws TechnicalException { if ( ! encrypted . startsWith ( getPrefix ( ) ) ) { logger . error ( TechnicalException . TECHNICAL_ERROR_MESSAGE_DECRYPT_EXCEPTION ) ; throw new TechnicalException ( Messages . getMessage ( TechnicalException . TECHNICAL_ERROR_MESSAGE_DECRYPT_EXCEPTION ) ) ; } Key aesKey = null ; if ( cryptoKey != null && ! "" . equals ( cryptoKey ) ) { aesKey = buildKey16char ( cryptoKey ) ; } if ( aesKey == null ) { logger . error ( TechnicalException . TECHNICAL_ERROR_MESSAGE_DECRYPT_CONFIGURATION_EXCEPTION ) ; throw new TechnicalException ( Messages . getMessage ( TechnicalException . TECHNICAL_ERROR_MESSAGE_DECRYPT_CONFIGURATION_EXCEPTION ) ) ; } try { Cipher cipher = Cipher . getInstance ( "AES" ) ; cipher . init ( Cipher . DECRYPT_MODE , aesKey ) ; return new String ( cipher . doFinal ( Base64 . decodeBase64 ( encrypted . substring ( getPrefix ( ) . length ( ) , encrypted . length ( ) ) ) ) ) ; } catch ( NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | IllegalBlockSizeException | BadPaddingException e ) { throw new TechnicalException ( Messages . getMessage ( TechnicalException . TECHNICAL_ERROR_MESSAGE_DECRYPT_EXCEPTION ) , e ) ; } }
{@inheritDoc}