Encryption Functions

Overview

Allows for the encryption and decryption of text data using symmetric AES encryption. This plug-in uses standard Java cryptography functions to expose expression functions for the encryption and decryption of data using AES.

Key Features & Functionality

Functions:

  • encryptvalue(): Encrypt plain text data using an AES encryption key stored in the Secure Credentials Store
  • decryptvalue(): Decrypt encrypted text data using an AES encryption key stored in the Secure Credentials Store

Features:

  • Supports up to 256-bit AES keys when JCE Unlimited Strength Jurisdiction Policy is enabled
  • Backwards compatible with older versions of Java lacking support for >128-bit encryption keys
Anonymous
  • Hi,

    I created a rule to encrypt/decrypt values using this plug-in and for both functions I use the same key defined in the Third party credential. 

    I first encrypt the value and store it in DB and then retrieve it in a process and decrypt the value. When trying to decrypt the encrypted value in the process I get the following error: 

    Expression evaluation error at function fn!decryptvalue [line 11]: Could not decrypt item of type javax.crypto.IllegalBlockSizeException: Input length must be multiple of 16 when decrypting with padded cipher. Item prepared for server was not encrypted: {1}.

    Has anyone face this issue before or has any idea on how to solve it? 

    Thanks in advance

  • HI ,

    Is there any document on how to configure field name, key and value in third part credentials?

     how to generate value ,is it automatically generated one ?

    In The expresseion: encryptvalue(valueToEncrypt:local!phoneNumber,
    externalSystemKey:"encryptdecryptkey",
    scsFieldKey:"key"

    ), what is mean by externalsystemkey and scsfieldkey

  • Hello, I have encrypted a field in the appian storage tables with AES_ENCRYPT and I have stored it by transforming it to HEX to leave it as text, but I want to create a rule that allows me to decrypt that field using the decryptvalue function, but I cannot make them compatible The encryption ones, do you know of any way that the encryption in MySQL and Appian with the functions are compatible?

  • Hello - Can I know what version a JUnit we can use to run the unit tests in the Encryption Functions plugin?

    Also, what version of JDK used to develop?

    I'm getting the following error trying to run the testEncryptedValueCanBeDecrypted test

    internal Error occurred.
    org.junit.platform.commons.JUnitException: TestEngine with ID 'junit-jupiter' failed to discover tests
        at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverEngineRoot(EngineDiscoveryOrchestrator.java:160)
        at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverSafely(EngineDiscoveryOrchestrator.java:132)
        at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discover(EngineDiscoveryOrchestrator.java:107)
        at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discover(EngineDiscoveryOrchestrator.java:78)
        at org.junit.platform.launcher.core.DefaultLauncher.discover(DefaultLauncher.java:110)
        at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
        at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
        at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
        at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:71)
        at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
        at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:221)
        at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
    Caused by: org.junit.platform.commons.JUnitException: MethodSelector [className = 'com.appiansolutionengineering.encryption.test.EncryptTextTest', methodName = 'testEncryptedValueCanBeDecrypted', methodParameterTypes = ''] resolution failed
        at org.junit.platform.launcher.listeners.discovery.AbortOnFailureLauncherDiscoveryListener.selectorProcessed(AbortOnFailureLauncherDiscoveryListener.java:39)
        at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolveCompletely(EngineDiscoveryRequestResolution.java:103)
        at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.run(EngineDiscoveryRequestResolution.java:83)
        at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolver.resolve(EngineDiscoveryRequestResolver.java:113)
        at org.junit.jupiter.engine.discovery.DiscoverySelectorResolver.resolveSelectors(DiscoverySelectorResolver.java:46)
        at org.junit.jupiter.engine.JupiterTestEngine.discover(JupiterTestEngine.java:69)
        at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverEngineRoot(EngineDiscoveryOrchestrator.java:152)
        ... 11 more
    Caused by: org.junit.platform.commons.PreconditionViolationException: Could not load class with name: com.appiansolutionengineering.encryption.test.EncryptTextTest
        at org.junit.platform.engine.discovery.MethodSelector.lambda$lazyLoadJavaClass$0(MethodSelector.java:157)
        at org.junit.platform.commons.function.Try$Failure.getOrThrow(Try.java:335)
        at org.junit.platform.engine.discovery.MethodSelector.lazyLoadJavaClass(MethodSelector.java:156)
        at org.junit.platform.engine.discovery.MethodSelector.getJavaClass(MethodSelector.java:135)
        at org.junit.jupiter.engine.discovery.MethodSelectorResolver.resolve(MethodSelectorResolver.java:75)
        at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.lambda$resolve$2(EngineDiscoveryRequestResolution.java:150)
        at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
        at java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1361)
        at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
        at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:499)
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:486)
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
        at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
        at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolve(EngineDiscoveryRequestResolution.java:189)
        at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolve(EngineDiscoveryRequestResolution.java:126)
        at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolveCompletely(EngineDiscoveryRequestResolution.java:92)
        ... 16 more
    Caused by: java.lang.ClassNotFoundException: com.appiansolutionengineering.encryption.test.EncryptTextTest
        at java.net.URLClassLoader.findClass(URLClassLoader.java:387)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
        at org.junit.platform.commons.util.ReflectionUtils.lambda$tryToLoadClass$9(ReflectionUtils.java:831)
        at org.junit.platform.commons.function.Try.lambda$call$0(Try.java:57)
        at org.junit.platform.commons.function.Try.of(Try.java:93)
        at org.junit.platform.commons.function.Try.call(Try.java:57)
        at org.junit.platform.commons.util.ReflectionUtils.tryToLoadClass(ReflectionUtils.java:794)
        at org.junit.platform.commons.util.ReflectionUtils.tryToLoadClass(ReflectionUtils.java:750)
        ... 32 more

  • I know the description above states that this plug-in supports encryption/decryption of plain text data but is there any reason why it would not work on other data types? In particular I'm thinking of date fields, e.g. used for Date Of Birth (I assume the encrypted value would have to be stored as text anyway). Or would you need to convert the date field to text before passing it to the encryptvalue() function?

  • Is there any way to check whether text is already encrypted or not?

  • Hi,

    i am trying to add a validation inside the a!encryptedTextField(), is there a way to add validations?

    there is no parameter for "validation".

    if you suggest that will be helpful.

    a!localVariables(
    local!accountNumber,
    {
    a!encryptedTextField(
    label: "Bank Account Number:",
    labelPosition: "ABOVE",
    value: local!accountNumber,
    saveInto: local!accountNumber,
    refreshAfter: "UNFOCUS",
    required: true,

    ),
    }
    )

  • Hi , glad you got it resolved. You are correct in that using a!encryptedTextField() is only supported with the native encryption APIs using the Appian generated key. The Encryption Functions plug-in needs to always be used with regular text fields and other components.

  • Ok, I got it resolved, it seems we cant use encryptedTextField() when encrypting, it worked with simple textField()

  • I forgot to add that I am using default systemkey and fieldkey for the test purposes.