Java
Encrypting/Decrypting data with our backend SDKs may expose you to greater compliance burden because your server needs to handle plaintext data. Instead, we recommend using Relay or our Client-Side SDKs to encrypt data.
Getting started
Install the SDK
First, let's install the Evervault SDK using either gradle or maven.
Initialize the SDK
Now, let's initialize the SDK using our App's ID and API key. If you don't have one yet, you can get one by creating an App in the Evervault Dashboard.
Encrypt a string
Now that the SDK is initialized, we can encrypt a string.
Reference
Evervault()
The SDK constructor takes two parameters; your App's ID and API key.
Parameters
Your Evervault App's ID.
Your Evervault App's API Key.
encrypt()
Encrypts data using Evervault Encryption. Evervault Strings can be used across all of our products.
To encrypt data using the Java SDK, simply pass a value into the evervault.encrypt() function. encrypt() will encrypt your data and return an object which is a String in case you passed a literal type like bool, String, int, float, char, byte.
The encrypted data can be stored in your database as normal and can be used with any of Evervault’s other services.
decrypt()
Decrypts the data previously encrypted with the encrypt() function or through Relay. An API key with the decrypt permission must be used to perform this operation.
Parameters
The data to decrypt.
The value type of the dat to deserialize into.
PCI Compliance
createClientSideDecryptToken()
Client Side Decrypt Tokens are versatile and short-lived tokens that frontend applications can utilise to decrypt data previously encrypted through Evervault. Client Side Decrypt Tokens are restricted to specific payloads.
By default, a Client Side Decrypt Token will live for 5 minutes into the future. The maximum time to live of the token is 10 minutes into the future.
Parameters
The payload containing encrypted data that the token will be used to decrypt.
The time the token will expire. Defaults to 5 minutes in the future.
run()
Lets you invoke an Evervault Function with a given payload. The function result will be deserialized into an instance of responseType and will be returned.
Parameters
The name of the function to invoke.
The payload to pass to the function.
The type into which the function's result will be serialized.
The request timeout defines the maximum duration the SDK will wait before aborting the function run if it has not completed.
createRunToken()
Creates a single use, time bound token (5 minutes) for invoking an Evervault Function with a given payload. Run Tokens can be used to invoke an Evervault Function client-side without providing a sensitive API Key.
Parameters
The name of the function to invoke.
Payload that the token can be used with. If not provided, a run token will be created, and the payload will not be validated when the function is executed.
Run Tokens can then be used to authenticate Function runs from the client-side.