Virgil SDK allows developers to get up and running with Virgil API quickly and add full end-to-end (E2EE) security to their existing digital solutions to become HIPAA and GDPR compliant and more.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Examples
Nuget
SDK/Source
.gitattributes
.gitignore
CONTRIBUTING.md
LICENSE.md
README.md
appveyor.yml
doxygen.config

README.md

Virgil Security .NET/C# SDK

Build status Nuget package GitHub license

Introduction | SDK Features | Installation | Usage Examples | Docs | Support

Introduction

Virgil Security provides a set of APIs for adding security to any application. In a few simple steps you can encrypt communication, securely store data, provide passwordless login, and ensure data integrity.

The Virgil SDK allows developers to get up and running with Virgil API quickly and add full end-to-end security to their existing digital solutions to become HIPAA and GDPR compliant and more.

SDK Features

Installation

The Virgil .NET SDK is provided as a package named Virgil.SDK. The package is distributed via NuGet package management system.

Supported Platforms:

  • .NET Standard 1.1+
  • .NET Framework 4.5+
  • .NET Core 1.0+
  • Universal Windows Platform 10
  • Windows 8.0+
  • Windows Phone 8.1+
  • Xamarin.Android 7.0+
  • Xamarin.iOS 10.0+
  • Xamarin.Mac 3.0+
  • Mono 4.6+ (OSX)

Installing the package using Package Manager Console:

Run PM> Install-Package Virgil.SDK

Usage Examples

Before start practicing with the usage examples be sure that the SDK is configured. Check out our SDK configuration guides for more information.

Generate and publish user's Cards with Public Keys inside on Cards Service

Use the following lines of code to create and publish a user's Card with Public Key inside on Virgil Cards Service:

using Virgil.Crypto;
using Virgil.SDK;

var crypto = new VirgilCrypto();

// generate a key pair
var keyPair = crypto.GenerateKeys();

// save a private key into key storage
privateKeyStorage.Store(keyPair.PrivateKey, "Alice");

// publish user's card on the Cards Service
var card = await cardManager.PublishCardAsync(
	new CardParams()
	{
	    PublicKey = keyPair.PublicKey,
	    PrivateKey = keyPair.PrivateKey,
	});

Sign then encrypt data

Virgil SDK lets you use a user's Private key and his or her Cards to sign, then encrypt any kind of data.

In the following example, we load a Private Key from a customized Key Storage and get recipient's Card from the Virgil Cards Services. Recipient's Card contains a Public Key on which we will encrypt the data and verify a signature.

using Virgil.CryptoImpl;
using Virgil.SDK;

// prepare a message
var messageToEncrypt = "Hello, Bob!";
var dataToEncrypt = Bytes.FromString(messageToEncrypt);

// prepare a user's private key
var (alicePrivateKey, alicePrivateKeyAdditionalData) = privateKeyStorage.Load("Alice");

// using cardManager search for Bob's cards on Cards Service
var cards = await cardManager.SearchCardsAsync("Bob");
var bobRelevantCardsPublicKeys = cards.Select(x => x.PublicKey).ToArray();

// sign a message with a private key then encrypt using Bob's public keys
var encryptedData = crypto.SignThenEncrypt(dataToEncrypt, alicePrivateKey, bobRelevantCardsPublicKeys);

Decrypt then verify data

Once the Users receive the signed and encrypted message, they can decrypt it with their own Private Key and verify signature with a Sender's Card:

using Virgil.CryptoImpl;
using Virgil.SDK;

// prepare a user's private key
var (bobPrivateKey, bobPrivateKeyAdditionalData) = privateKeyStorage.Load("Bob");

// using cardManager search for Alice's cards on Cards Service
var cards = await cardManager.SearchCardsAsync("Alice");
var aliceRelevantCardsPublicKeys = cards.Select(x => x.PublicKey).ToArray();

// decrypt with a private key and verify using one of Alice's public keys
var decryptedData = crypto.DecryptThenVerify(encryptedData, bobPrivateKey, aliceRelevantCardsPublicKeys);

Docs

Virgil Security has a powerful set of APIs, and the documentation below can get you started today.

In order to use the Virgil SDK with your application, you will need to first configure your application. By default, the SDK will attempt to look for Virgil-specific settings in your application but you can change it during SDK configuration.

License

This library is released under the 3-clause BSD License.

Support

Our developer support team is here to help you. Find out more information on our Help Center.

You can find us on Twitter or send us email support@VirgilSecurity.com.

Also, get extra help from our support team on Slack.