Go Sample Application

Run demonstration test encrypt and decrypt calls with this sample application

Overview

This sample application will demonstrate how to encrypt and decrypt data using the different APIs.

Installation

Make sure Go is installed on your system.

On Debian and Debian-like Linux systems:

sudo apt install golang

For MacOS, Windows, and other Linux systems, see the Go installation page.

Credentials file

Edit the credentials file with your account credentials created using the Ubiq dashboard:

[default]
ACCESS_KEY_ID = ...  
SECRET_SIGNING_KEY = ...  
SECRET_CRYPTO_ACCESS_KEY = ...

Build the examples

Create a local directory and compile the example application:

git clone https://gitlab.com/ubiqsecurity/ubiq-go.git
cd ubiq-go/examples
go get
go build ubiq_sample.go

Older versions of Go may produce a message like the following:

go get: no install location for directory /path/to/ubiq-go/examples outside GOPATH
    For more details see: 'go help gopath'

This can be safely ignored for the purpose of building the example.

Example for Unstructured Data

View Program Options

From within the examples directory:

./ubiq_sample -h
Usage: ./ubiq_sample -e|-d -s|-p -i INFILE -o OUTFILE
Encrypt or decrypt files using the Ubiq service

  -h, -help               Show this help message and exit
  -V, -version            Show program's version number and exit
  -e, -encrypt            Encrypt the contents of the input file and write
                            the results to the output file
  -d, -decrypt            Decrypt the contents of the input file and write
                            the results to the output file
  -s, -simple             Use the simple encryption / decryption interfaces
  -p, -piecewise         Use the piecewise encryption / decryption interfaces
  -i INFILE, -in INFILE   Set input file name
  -o OUTFILE, -out OUTFILE
                          Set output file name
  -c CREDENTIALS, -creds CREDENTIALS
                          Set the file name with the API credentials
                            (default: ~/.ubiq/credentials)
  -P PROFILE, -profile PROFILE
                          Identify the profile within the credentials file

Demonstrate using the simple (-s / -simple) API interface to encrypt this README.md file and write the encrypted data to /tmp/readme.enc

./ubiq_sample -i README.md -o /tmp/readme.enc -e -s -c ./credentials

Demonstrate using the simple (-s / -simple) API interface to decrypt the /tmp/readme.enc file and write the decrypted output to /tmp/README.out

./ubiq_sample -i /tmp/readme.enc -o /tmp/README.out -d -s -c ./credentials

Demonstrate using the piecewise (-p / -piecewise) API interface to encrypt this README.md file and write the encrypted data to /tmp/readme.enc

./ubiq_sample -i README.md -o /tmp/readme.enc -e -p -c ./credentials

Demonstrate using the piecewise (-p / -piecewise) API interface to decrypt the /tmp/readme.enc file and write the decrypted output to /tmp/README.out

./ubiq_sample -i /tmp/readme.enc -o /tmp/README.out -d -p -c ./credentials