Class EncryptionUtil
java.lang.Object
com.mirth.connect.server.userutil.EncryptionUtil
This utility class provides some convenience methods for encrypting or decrypting data.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringConvenience method for decrypting data.static byte[]Convenience method for decrypting data.static EncryptedDataencrypt(byte[] data) Convenience method for encrypting data.static StringConvenience method for encrypting data.
-
Constructor Details
-
EncryptionUtil
public EncryptionUtil()
-
-
Method Details
-
encrypt
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
EncryptedDataobject containing the header information and encrypted data. - Throws:
com.mirth.commons.encryption.EncryptionException- If the data cannot be encrypted for any reason.
-
decrypt
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 theencrypt(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.
-