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.
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>();
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
string customerName;
try
{
using var cbc = _cipherFactory.CreateCbcProvider();
customerName = cbc.Decrypt(customerNameCipher, key, iv);
}
catch (CryptographicException e)
{
}
catch (ArgumentException e)
{
}
var generator = new UrlFriendlyStringGenerator();
var value = generator.CreateUniqueString(24);