Ruby 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 to first install the ubiq-security Ruby Client Library if you have not done so yet:

gem install ubiq-security

Then from within the example directory using Bundler:

cd example
bundle install
ruby ubiq_sample.rb -h

Credentials file

Edit the API Key Credentials file with your account API Key Credentials created using the Ubiq Dashboard.

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

Example for Unstructured Data

View program options

From within the example directory:

cd example
ruby ubiq_sample.rb -h
Usage: ubiq_sample [options]
    -h, --help            Show this help message and exit
    -V, --version         Show program's version number and exit
    -e                    Encrypt the contents of the input file and write the results to output file
    -d                    Decrypt the contents of the input file and write the results to output file
    -s,                   Use the simple encryption / decryption interfaces
    -p,                   Use the piecewise encryption / decryption interfaces
    -i, --infile INFILE
                          The input file containing the data to be encrypted/decrypted
    -o, --outfile OUTFILE
                          The output file containing the result after encryption/decryption
    -c, --credentials CREDENTIALS
                          The name of the credentials file from where keys will be loaded
    -P PROFILE, --profile PROFILE
                          Identify the profile within the credentials file (default: default)

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

ruby ubiq_sample.rb -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

ruby ubiq_sample.rb -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

ruby ubiq_sample.rb -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

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