FluentCrossPlatformCrypto 0.1.0

dotnet add package FluentCrossPlatformCrypto --version 0.1.0                
NuGet\Install-Package FluentCrossPlatformCrypto -Version 0.1.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="FluentCrossPlatformCrypto" Version="0.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FluentCrossPlatformCrypto --version 0.1.0                
#r "nuget: FluentCrossPlatformCrypto, 0.1.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 FluentCrossPlatformCrypto as a Cake Addin
#addin nuget:?package=FluentCrossPlatformCrypto&version=0.1.0

// Install FluentCrossPlatformCrypto as a Cake Tool
#tool nuget:?package=FluentCrossPlatformCrypto&version=0.1.0                

Overview

FluentCrossPlatformCrypto is a wrapper offering

  • a fluent interface on top of some .NET native cryptography functions
  • the same interface in a browser-wasm environment using interop to the JavaScript Web Crypto API

Warning

Please keep in mind that this library is a wrapper around cryptography APIs and the keys might be visible to any code having access to the computer memory.

Available Algorithms

Feature .NET System.Security.Cryptography Web Crypto API
Digest SHA1 / SHA256 / SHA384 / SHA512 subtle.digest
Encrypt / Decrypt Aes / RSA subtle.encrypt / decrypt
Sign / Verify RSA / ECDsa / HMAC subtle.sign / verify
Key Derivation ECDiffieHellman / Rfc2898DeriveBytes / HKDF subtle.deriveBits

Examples

RSA signature verification

var rsaPublicKey = await Algorithm.Rsa.Pss[Algorithm.Digest.Sha256].Import
  .Spki("the signer public key in base64".FromBase64());
var isValid = await rsaPublicKey.Verify(
    Encoding.UTF8.GetBytes("the signed message"),
    "the signature in base64".FromBase64()
  );

AES encryption after PBKDF2 password derivation

var pbkdf2 = await Algorithm.Pbkdf2[Algorithm.Digest.Sha256].Import.Text("My password");
var aes = await pbkdf2.With(iterations:1000).DeriveToAes();
var encrypted = await aes.Encrypt("My secret information");

EC DiffieHellman exchange followed by HKDF derivation

var import = Algorithm.Ec.P521.Dh[Algorithm.Digest.Sha384].Import;
var alicePrivateKey = await import.Pkcs8("Alice private key".FromBase64());
var bobPublicKey = await import.Spki("Bob public key".FromBase64());
var sharedSecret = await alicePrivateKey.With(bobPublicKey).Derive();
var hkdf = await Algorithm.Hkdf[Algorithm.Digest.Sha256].Import.Raw(sharedSecret);
var dedicatedKey = await hkdf.With(info: "for some intent").DeriveToAes();
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net7.0

    • No dependencies.

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
0.1.0 519 9/27/2023