Class EncryptionUtil

java.lang.Object
com.mirth.connect.server.userutil.EncryptionUtil

public class EncryptionUtil extends Object
This utility class provides some convenience methods for encrypting or decrypting data.
  • Constructor Details

    • EncryptionUtil

      public EncryptionUtil()
  • Method Details

    • encrypt

      public static String encrypt(String data) throws com.mirth.commons.encryption.EncryptionException
      Convenience method for encrypting data. Uses the currently configured encryption settings.
      Parameters:
      data - The data to encrypt, as a String.
      Returns:
      The encrypted data.
      Throws:
      com.mirth.commons.encryption.EncryptionException - If the data cannot be encrypted for any reason.
    • encrypt

      public static EncryptedData encrypt(byte[] data) throws com.mirth.commons.encryption.EncryptionException
      Convenience method for encrypting data. Uses the currently configured encryption settings.
      Parameters:
      data - The data to encrypt, as a raw byte array.
      Returns:
      An EncryptedData object containing the header information and encrypted data.
      Throws:
      com.mirth.commons.encryption.EncryptionException - If the data cannot be encrypted for any reason.
    • decrypt

      public static String decrypt(String data) throws com.mirth.commons.encryption.EncryptionException
      Convenience method for decrypting data. Uses the currently configured encryption and fallback settings.
      Parameters:
      data - The data to decrypt, as a String.
      Returns:
      The decrypted data.
      Throws:
      com.mirth.commons.encryption.EncryptionException - If the data cannot be decrypted for any reason.
    • decrypt

      public static byte[] decrypt(String header, byte[] data) throws com.mirth.commons.encryption.EncryptionException
      Convenience method for decrypting data. Uses the currently configured encryption and fallback settings.
      Parameters:
      header - The meta-information about the encrypted data. This is a specially-formatted string returned from the encrypt(byte[]) method.
      data - The data to decrypt, as a raw byte array.
      Returns:
      The decrypted data.
      Throws:
      com.mirth.commons.encryption.EncryptionException - If the data cannot be decrypted for any reason.