public static String encrypt(final String plainText, final String password) throws Exception {
        if (plainText == null) {
            return null;
        }

        final byte[] salt = getRandomNonce(SALT_LENGTH);
        final byte[] iv = getRandomNonce(IV_LENGTH);
        final SecretKey aesKey = getAESKeyFromPassword(password, salt);
        final Cipher cipher = Cipher.getInstance(CRYPTO_ALGORITHM);
        cipher.init(Cipher.ENCRYPT_MODE, aesKey, new GCMParameterSpec(TAG_LENGTH, iv));

        final byte[] cipherText = cipher.doFinal(plainText.getBytes(StandardCharsets.UTF_8));
        final byte[] cipherTextWithIvSalt = ByteBuffer.allocate(iv.length + salt.length + cipherText.length)
            .put(iv)
            .put(salt)
            .put(cipherText)
            .array();

        return Base64.getEncoder().encodeToString(cipherTextWithIvSalt);
    }
Encrypt a plain-text string and encode the result in base-64
@return Base-64 encoded cipher text
stroom-core-shared/src/main/java/stroom/crypto/shared/CryptoUtils.java