Guides
Android SDK
Evervault Android SDK
The Evervault Android SDK is a library that provides secure data encryption and secure credit card input. It's simple to integrate, easy to use and it supports a wide range of data types.
Features
- Core encryption capabilities for various data types. A secure and customizable PaymentCardInput Compose view.
- Built-in data type recognition and appropriate encryption handling.
Supported Platforms
- Android
Related Projects
The Evervault Android SDK uses the Evervault Kotlin Multiplatform SDK to provide the core encryption functionality.
Installation
Our Android SDK distributed via maven, and can be installed using your preferred build tool.
Gradle DSL
Maven
Usage
Configuration
Before using the Evervault Android SDK, you need to configure it with your Evervault Team ID and App ID. This step is essential for establishing a connection with the Evervault encryption service.
Make sure to replace <TEAM_ID>
and <APP_ID>
with your actual Evervault Team ID and App ID.
Encrypting Data
Once the SDK is configured, you can use the encrypt
method to encrypt your sensitive data. The encrypt
method accepts various data types, including Boolean, Numerics, Strings, Arrays, Lists, Maps and ByteArrays.
Here's an example of encrypting a password:
The encrypt
method returns an Any
type, so you will need to safely cast the result based on the data type you provided. For Boolean, Numerics, and Strings, the encrypted data is returned as a String. For Arrays, Lists and Maps, the encrypted data maintains the same structure but is encrypted (except that Arrays become Lists). For ByteArray, the encrypted data is returned as encrypted ByteArray, which can be useful for encrypting files.
Decrypting Data
Decrypts data previously encrypted with the encrypt()
function or through Relay.
The decrypt()
function allows you to decrypt previously encrypted data using a token.
The token is a time bound token for decrypting data. The token can be generated using our backend SDKs or through our REST API.
The payload must be the same payload that was used to create the token and expires in a maximum of 10 minutes depending on the expiry set when creating the token.
The payload must be a map and the response is Any
which can, and should be, cast to Map<String, Any>
Inputs
The Evervault Android SDK also provides a Compose view called PaymentCardInput
. This view is designed for capturing credit card information and automatically encrypts the credit card number and CVC without exposing the unencrypted data. The PaymentCardInput
view can be customized to fit your application's design.
Here's an example of using the PaymentCardInput
view:
The encrypted credit card number and CVC are captured in the PaymentCardData
, as well as the expiry month and year and validation fields.
Styling
The PaymentCardInput
can be customized to fit your application's design. The view accepts a layout
parameter, which can be used to customize the view's layout. The layout
parameter accepts a @Composable
function, which can be used to customize the view's layout.
Two build-in layouts are provided:
inlinePaymentCardInputLayout()
(the default layout) - This layout displays the card number, expiry and CVC fields inline.
<img src="https://github.com/evervault/evervault-android/blob/main/inline.png?raw=true" alt="inlinePaymentCardInputLayout" align="center"/>
To explicitly use this layout:
rowsPaymentCardInputLayout()
- puts the credit card number on a single row. Below it, places the expiry and cvc fields next to each other.
<img src="https://github.com/evervault/evervault-android/blob/main/rows.png?raw=true" alt="rowsPaymentCardInputLayout" align="center"/>
To use this layout:
You can also customize these layout through theming and modifiers:
If these two layouts do not fit your application's design, you can create your own layout by passing a @Composable
function to the layout
parameter. The @Composable
function will receive a PaymentCardInputScope
object, which contains the CardImage
, CardNumberField
, ExpiryField
and CVCField
fields. You can use these fields to create your own layout:
Cages (Beta)
The Evervault Cages SDK provides an accessible solution for developers to deploy Docker containers within a Secure Enclave. It enables you to interact with your Cages endpoints via standard HTTP requests directly from your Android applications. A key feature that enables this is the attestation verification performed before completing the TLS handshake. For a deeper understanding of this process, you can explore our TLS Attestation documentation.
The attestation verification is executed using a custom Trust Manager on a OkHttpClient.Builder
. This Trust Manager needs initialization with one or more AttestationData
objects:
It is crucial to ensure that the supplied PCRs align with the PCRs of the respective Cage.
Then you configure the HTTP Client with the attestations:
Only use this client for requests to your Cage. For all other requests, use a separate client.
Considerations
- It's crucial to note that the PCR values associated with a Cage change with each new deployment. Consequently, older versions of your app with hardcoded PCRs may stop functioning. To alleviate this, you can accommodate previous deployments by providing multiple
PCRs
objects:
- Please be aware that the Android SDK is compatible only with Cages that have the API Key Authentication set to
false
in your cage.toml file:
Only use the
OkHttpClient
configured with theAttestationData
for requests to your Cage. For all other requests, use a separate client. If you have multiple Cages, you will need to configure a separateOkHttpClient
for each Cage.When calling an endpoint of your Cage, use make sure you do not have any underscore
_
in the request url. Replace any underscore, such as the one in your App ID, with hyphens-
.
These considerations are essential to remember for a seamless integration and operation of the Evervault Cages SDK in your Android applications.
Sample App
The Evervault Android SDK Package includes a sample app, located in the sampleapplication
directory. The sample app demonstrates various use cases of the SDK, including string encryption, file (image) encryption, and the usage of the PaymentCardInput
view with customized styling.
License
The sample app is released under the MIT License. See the LICENSE file for more information.
Feel free to experiment with the sample app to understand the capabilities of the Evervault iOS SDK and explore different integration options for your own projects.
Contributing
Bug reports and pull requests are welcome on GitHub.
Feedback
Questions or feedback? Let us know.