Data tokenization and encryption using Go
The Basis Theory Go SDK simplifies data tokenization and encryption with one of the world’s fastest-growing program languages.
There are an estimated 1.1 million Go developers today, making Go one of the top 10 languages in the world. The 2021 StackOverflow Developer Survey shows it’s one of the most wanted and least dreaded languages for developers. So it seems only natural to support a full Go SDK, yet surprisingly many products and services lack a Go SDK. So why did Basis Theory decide to build one?
Last month, we built a Terraform provider to help developers manage their Tenants and Applications with code, rather than manually managing their tokenization infrastructure from our web portal. Terraform modules are written in Go, and thus our initial Go SDK was born.
Installing the Go SDK
If you haven’t already, take the next 30 seconds to sign up for a free account (no credit card required). Once registered, we’ll automatically provision your first PCI-compliant Tenant in our Web Portal. Create an Application to get started!
Install a Go module by calling the <span class="code">go get</span> command or importing the module directly from GitHub. To install the Basis Theory Go SDK and its dependencies, run the following commands:
Alternatively, you can import the package directly in your own modules:
Note: at the time of writing, the latest version was v3. You can find the latest version in our documentation.
Using the Go SDK
The SDK supports all of Basis Theory’s public API endpoints and is thoroughly documented in our API Reference guide. Let’s look at some of the most common operations and how you would perform them using Go!
Creating a new Application
Applications provide a set of permissions used to access your data using an API key. Applications represent a system or component that needs to access your data in a secure and compliant manner. Any type of system can be an application. For instance, front-end clients that can only write data, or server-to-server systems that need to read or share the data.
Regenerating an Application Key
Basis Theory manages the rotation of Encryption Keys on your behalf, helping you minimize the risk of your data being compromised. For those looking to automate their API key management process, Basis Theory provides a way to automatically regenerate API keys.
Creating a Token
Once you have your Applications configured, you are ready to start creating Tokens. A Token represents a piece of data that you want to be securely stored. The Token is a unique, undecipherable identifier that references your sensitive data, and is the core of the Basis Theory Platform.
Decrypting a Token
After creating a Token, you may need to read all or part of the plain text value back. It’s as easy as making a call to the Basis Theory API!
Invoking a Reactor
There are risks with using sensitive values within your systems. For example, a sensitive value could be stored in memory for a short time and read by an attacker, or misconfigured logging could accidentally write sensitive data to a log file. Reactors solve this issue by providing a secure, compliant, serverless compute environment where you can execute your custom code to interact with the tokenized data— without that data touching your systems.
As the popularity of Go continues to rise, more and more enterprises will be using it to not only manage their infrastructure, but also to power their applications. The need for better security— and better developer experiences around data security—will only continue to grow. The Basis Theory Go SDK makes satisfying data security and compliance requirements fit seamlessly into your development lifecycle.
Want to try it for yourself? Create a free account to spin up your PCI Level 1 and SOC 2 certified environment in less than a minute—without adding a credit card.