Class EncryptionUtil


  • public final class EncryptionUtil
    extends Object
    Encryption utilities for secrets protection.
    • Method Detail

      • decryptRsa

        public static String decryptRsa​(PrivateKey key,
                                        String encryptedBase64)
                                 throws ConfigEncryptionException
        Decrypt using RSA with OAEP. Expects message encrypted with the public key.
        Parameters:
        key - private key used to decrypt
        encryptedBase64 - base64 encoded encrypted secret
        Returns:
        Secret value
        Throws:
        ConfigEncryptionException - If any problem with decryption occurs
      • decryptRsaLegacy

        public static String decryptRsaLegacy​(Key key,
                                              String encryptedBase64)
                                       throws ConfigEncryptionException
        Decrypt using RSA (private or public key). Expects message encrypted with the other key.
        Parameters:
        key - private or public key to use to decrypt
        encryptedBase64 - base64 encoded encrypted secret
        Returns:
        Secret value
        Throws:
        ConfigEncryptionException - If any problem with decryption occurs
      • encryptAes

        public static String encryptAes​(char[] masterPassword,
                                        String secret)
                                 throws ConfigEncryptionException
        Encrypt using AES with GCM method, key is derived from password with random salt.
        Parameters:
        masterPassword - master password
        secret - secret to encrypt
        Returns:
        Encrypted value base64 encoded
        Throws:
        ConfigEncryptionException - If any problem with encryption occurs