interconnect/model/src/main/java/de/taimos/dvalin/interconnect/model/MessageCryptoUtil.java
/**
     * @param data the BASE 64 data
     * @return the decrypted data
     * @throws CryptoException on decryption error
     */
@param data the BASE 64 data
@return the decrypted data
@throws CryptoException on decryption error
@param data the BASE 64 data @return the decrypted data @throws CryptoException on decryption error
public static String decrypt(final String data) throws CryptoException {
        if (data == null) {
            return null;
        }
        try {
            byte[] cipherMessage = Base64.decodeBase64(data);
            AlgorithmParameterSpec gcmIv = new GCMParameterSpec(128, cipherMessage, 0, 12);
            final Cipher cipher = MessageCryptoUtil.getCipher(Cipher.DECRYPT_MODE, gcmIv);
            return new String(cipher.doFinal(cipherMessage, 12, cipherMessage.length - 12), StandardCharsets.UTF_8);
        } catch (final Exception e) {
            throw new CryptoException("Decryption of data failed!", e);
        }
    }
public static String decrypt ( final String data ) throws CryptoException { if ( data == null ) { return null ; } try { byte [ ] cipherMessage = Base64 . decodeBase64 ( data ) ; AlgorithmParameterSpec gcmIv = new GCMParameterSpec ( 128 , cipherMessage , 0 , 12 ) ; final Cipher cipher = MessageCryptoUtil . getCipher ( Cipher . DECRYPT_MODE , gcmIv ) ; return new String ( cipher . doFinal ( cipherMessage , 12 , cipherMessage . length - 12 ) , StandardCharsets . UTF_8 ) ; } catch ( final Exception e ) { throw new CryptoException ( "Decryption of data failed!" , e ) ; } }
@param data the BASE 64 data
 @return the decrypted data
 @throws CryptoException on decryption error
@param data the BASE 64 data @return the decrypted data @throws CryptoException on decryption error