Ruby
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
Our Ruby SDK is distributed via RubyGems, and can be installed via the command line or a Gemfile.
ruby gem 'evervault' Initialize the SDK
The SDK needs to be initialized with an 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
encrypt
Encrypts data using Evervault Encryption. Evervault Strings can be used across all of our products. To encrypt data using the Ruby SDK, simply pass a String, Hash or Array into the encrypt() method. 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.
PCI Compliance
create_client_side_decrypt_token
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 data 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.
Parameters
The name of the function to invoke.
The payload to pass to the function.
Successful Function runs will return a hash containing a Function Run ID and the result from your Function in the following format:
create_run_token
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
Name of the Function the Run Token is for.
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.
When you create a Run Token, the SDK will return a JSON object containing your token.
Run Tokens can then be used to authenticate Function runs from the client-side.
enable_outbound_relay
This should only be used when you need to configure third party SDKs with Relay. All other use cases should call Relay with a HTTP Client.
Configures your application to proxy HTTP requests using Relay based on the configuration created in the Evervault dashboard.