C#.NET Sample Application

Run demonstration test encrypt and decrypt calls with this sample application

Overview

The Ubiq Security dotnet (.NET) library provides convenient interaction with the Ubiq Security Platform API from applications written in the C# language for .NET. It includes a pre-defined set of classes that will provide simple interfaces to encrypt and decrypt data.

Documentation

See the .NET API docs.

Build from Source

  1. Download the reference source from the GitLab repository.
  2. Open the ubiq-dotnet.sln in Visual Studio.
  3. Select the CoreConsole project as the Startup Project.
  4. Select the Release Solution Configuration.
  5. and Any CPU Solution Configuration.
  6. Select Build->Rebuild Solution.

Note, if you get the error "The framework 'Microsoft.NETCore.App', version '2.0.0' was not found.", you'll need to install this framework by downloading: NetCore Version 2.0.0 for Console Apps.

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 = ...

View Program Options

For CoreConsole

Open a Windows command shell and change to the CoreConsole executable folder:

cd CoreConsole
dotnet bin\Release\netcoreapp2.0\CoreConsole.dll --help

For WinConsole

Open a Windows command shell and change to the WinConsole executable folder:

cd WinConsole
bin\Release\WinConsole.exe --help

From within the directory:

-e, --encrypt      (Default: false) Encrypt the contents of the input file and write the results to output file
-d, --decrypt      (Default: false) Decrypt the contents of the input file and write the results to output file
-s, --simple       (Default: false) Use the simple encryption / decryption interfaces
-p, --piecewise    (Default: false) Use the piecewise encryption / decryption interfaces
-i, --in           Required. Set input file name
-o, --out          Required. Set output file name
-c, --creds        Set the file name with the API credentials
-P, --profile      (Default: default) Identify the profile within the credentials file
--help             Display this help screen.
--version          Display version information.

Demonstrate

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

For CoreConsole

dotnet bin\Release\netcoreapp2.0\CoreConsole.dll -i README.md -o README.enc -e -s -c credentials

For WinConsole

bin\Release\WinConsole.exe -i README.md -o README.enc -e -s -c credentials

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

For CoreConsole

dotnet bin\Release\netcoreapp2.0\CoreConsole.dll -i README.enc -o README.out -d -s -c credentials

For WinConsole

bin\Release\WinConsole.exe -i README.enc -o 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 README.enc

For CoreConsole

dotnet bin\Release\netcoreapp2.0\CoreConsole.dll -i README.md -o README.enc -e -p -c credentials

For WinConsole

bin\Release\WinConsole.exe -i README.md -o README.enc -e -p -c credentials

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

For CoreConsole

dotnet bin\Release\netcoreapp2.0\CoreConsole.dll -i README.enc -o README.out -d -p -c credentials

For WinConsole

bin\Release\WinConsole.exe -i README.enc -o README.out -d -p -c credentials

Ubiq Format Preserving Encryption (eFPE)

This library also incorporates Ubiq Format Preserving Encryption (eFPE). eFPE allows encrypting so that the output cipher text is in the same format as the original plaintext. This includes preserving special characters and control over what characters are permitted in the cipher text. For example, consider encrypting a social security number '123-45-6789'. The cipher text will maintain the dashes and look something like: 'W$+-qF-oMMV'.

Build from Source

  1. Download the reference source from the GitLab repository.
  2. Open the ubiq-dotnet.sln in Visual Studio.
  3. Select the CoreConsole project as the Startup Project.
  4. Select the Release Solution Configuration.
  5. Select Any CPU Solution Configuration.
  6. Select Build->Rebuild Solution.

Note, if you get the error "The framework 'Microsoft.NETCore.App', version '2.0.0' was not found.", you'll need to install this framework by downloading: NetCore Version 2.0.0 for Console Apps.

Credentials file

Edit the credentials file with your account credentials created using the Ubiq dashboard. By default, the application will look for the file called "credentials" within the CoreConsoleFpe directory.

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

View Program Options

Open a Windows command shell and change to the CoreConsoleFpe executable folder:

cd CoreConsoleFpe
dotnet bin\Release\netcoreapp2.0\CoreConsoleFpe.dll --help
Usage: Ubiq Security Example [options]
    Options:
        -e, --encrypttext    Set the field text value to encrypt and will return the encrypted cipher text
        -d, --decrypttext    Set the cipher text value to decrypt and will return the decrypted text
        -s, --simple         (Default: false) Use the simple encryption / decryption interfaces
        -b, --bulk           (Default: false) Use the bulk encryption / decryption interfaces
        -n, --ffsname        Set the ffs name, for example SSN
        -h, --help           (Default: false) Print app parameter summary
        -c, --creds          Set the file name with the API credentials
        -P, --profile        (Default: default) Identify the profile within the credentials file
        -V, --version        Show program's version number and exit
        --help               Display this help screen.
        --version            Display version information.

Demonstrate encrypting a social security number and returning a cipher text

dotnet bin\Release\netcoreapp2.0\CoreConsoleFpe.dll  -e '123-45-6789' -c credentials -n ALPHANUM_SSN -s

Demonstrate decrypting a social security number and returning the plain text

dotnet bin\Release\netcoreapp2.0\CoreConsoleFpe.dll  -d 'W#]-iV-`,\"j' -c credentials -n ALPHANUM_SSN -s