pvWay.Crypto.Core 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package pvWay.Crypto.Core --version 1.0.0                
NuGet\Install-Package pvWay.Crypto.Core -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="pvWay.Crypto.Core" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add pvWay.Crypto.Core --version 1.0.0                
#r "nuget: pvWay.Crypto.Core, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install pvWay.Crypto.Core as a Cake Addin
#addin nuget:?package=pvWay.Crypto.Core&version=1.0.0

// Install pvWay.Crypto.Core as a Cake Tool
#tool nuget:?package=pvWay.Crypto.Core&version=1.0.0                

Crypto Core

Tiny utilily encrypting/decrypting texts/objects to/from base64 strings

Interfaces

This nuGet has only one public class implementing the following interface

ICrypto

using System;
using System.Threading.Tasks;

namespace pvWay.Crypto.Core
{
    public interface ICrypto: IAsyncDisposable, IDisposable
    {
        Task<string> EncryptAsync(string text);
        Task<string> EncryptAsync<T>(T data) where T: class;

        Task<string> DecryptAsync(string base64String);
        Task<T> DecryptAsync<T>(string base64String) where T: class;
    }
}

Usage

See here after a short Console that use the pool

The code

using System;
using pvWay.Crypto.Core;

namespace CryptoConsole
{
    internal static class Program
    {
        private const string InitializationVectorString = "0123456789ABCDEF";
        private const string KeyString = "123456789 123456789 123456789 12";

        private static void Main(/*string[] args*/)
        {
            var crypto = new Crypto(KeyString, InitializationVectorString);

            var b64 = crypto.EncryptAsync("test").Result;
            Console.WriteLine(b64);
            var text = crypto.DecryptAsync(b64).Result;
            Console.WriteLine(text);

            var mc = new MyClass
            {
                TheHeader = "header",
                TheBody = "Body",
                TheFooter = "Footer"
            };

            b64 = crypto.EncryptAsync(mc).Result;
            Console.WriteLine(b64);
            var mcBack = crypto.DecryptAsync<MyClass>(b64).Result;
            Console.WriteLine(mcBack.TheHeader);
            Console.WriteLine(mcBack.TheBody);
            Console.WriteLine(mcBack.TheFooter);

        }

        private class MyClass
        {
            public string TheHeader { get; set; }
            public string TheBody { get; set; }
            public string TheFooter { get; set; }
        }

    }
}

Happy coding

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.1 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.2 220 4/7/2023
2.0.0 730 9/27/2020
1.0.0 489 9/27/2020

Initial verson