Skip to content
This repository has been archived by the owner on May 20, 2022. It is now read-only.

Blockchain-agnostic tools for developing smart contract based applications

License

Notifications You must be signed in to change notification settings

drmathias/SmartContract.Essentials

Repository files navigation

⚠️ This repository is not maintained ⚠️


SmartContract.Essentials

Build Status Nuget

Overview

This is a set of tools that can be used to simplify the development of smart contract applications. Currently the tools included can be used for data encryption and string generation.

Usage

Setting up DI

Encryption providers can be created through a factory, allowing you to adhere to SOLID guidelines and test your implementation more easily. Begin by adding the factory to your container.

services.AddSingleton<ICipherFactory, AesCipherFactory>();

Encrypting personal data

var customerName = "Benjamin Swift";

CbcResult customerNameEncryptionResult;
try
{
    using var cbc = _cipherFactory.CreateCbcProvider();
    customerNameEncryptionResult = cbc.Encrypt(customerName);
}
catch (CryptographicException e)
{
}
catch (ArgumentException e)
{
}

// persist cipher to contract
// give user control of key and IV

Decrypting personal data

string customerName;
try
{
    using var cbc = _cipherFactory.CreateCbcProvider();
    customerName = cbc.Decrypt(customerNameCipher, key, iv);
}
catch (CryptographicException e)
{
}
catch (ArgumentException e)
{
}

Generating a random string

var generator = new UrlFriendlyStringGenerator();
var value = generator.CreateUniqueString(24);

About

Blockchain-agnostic tools for developing smart contract based applications

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages