Go

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


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.

Connecting to an Enclave


The returned client will be configured to connect to the Enclave and attest the connection on each request with the pcrs provided.

To keep your clients in sync with your Enclave across deployments, you can use the EnclaveClientWithProvider. This allows you to define a callback function which returns a list of PCRs. This can be used to load the latest set of PCRs for your Deployed Enclave from a trusted source without a redeploy of your client.

Reference


The full reference is available on Go pkg.

Encrypt


Encrypts data using Evervault Encryption. Evervault Strings can be used across all of our products. The encrypted data can be stored in your database as normal and can be used with any of Evervault’s other services.

Parameters

  • dataRequired

    The data to encrypt.

Decrypt


Decrypt data previously encrypted with the Encrypt function or through Relay. An API key with the decrypt permission must be used to perform this operation.

PCI Compliance

Decrypting data with our backend SDKs is not available if you are part of the PCI or HIPAA compliance use cases. Instead you can:

  • Use Relay to decrypt data before it reaches third-party services.
  • Use Functions or Enclaves to process encrypted data.

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

  • payloadRequiredstring

    The payload containing encrypted data that the token will be used to decrypt.

  • expirytime.Time

    The time the token will expire. Defaults to 5 minutes in the future.

RunFunction


Invoke an Evervault Function with a given payload.

Parameters

  • functionNameRequiredstring

    The name of the function to invoke.

  • payloadRequiredmap[string]any

    The payload containing encrypted data that will be passed as an argument to the Function.