/net5-crypto-tutorial

Tutorial and sample codes for .NET 5 Crypto topics

Primary LanguageC#MIT LicenseMIT

Tutorial and sample codes for .NET 5 Crypto related topics

Overview

This is a simple console app and you can choose the action you want to run.

This shows sample codes for the following:

Folder structure

  • app\Certificates folder: This includes codes to
    • Create self-signed certificate.
    • Issue signed certificate.
    • Get certificate information.
    • Validate the certificate chain.
    • Get certificate object with the target storage flag.
  • app\CertificateStore folder: This includes codes to
    • Find certificate from cert store by name or by thumbprint.
    • Add certificate into cert store.
    • Remove certificate from cert store.
  • app\EncryptionDecryption folder: This includes codes to
    • Do symmetric AES GCM encryption and decryption.
    • Do asymmetric RSA encryption and descryption.
  • app\Signature folder: This includes codes to
    • Sign the hash using RSA PKCS#1, and validate it.
    • Sign the message using CMS PKCS#7, and validate it.
  • app\TcpOperations folder: This includes codes to
    • Create TCP listener with the choice to use TLS
    • Create TCP client with the choice to use TLS

GitHub Actions included

  • DOTNET build and test
  • CodeQL

Useful NET CLI commands

  • (Create the default console app.)(Run in app folder.) dotnet new console --framework net5.0
  • dotnet run --project app\app.csproj

Extra packages

  • (For CmsSigner) dotnet add package System.Security.Cryptography.Pkcs --version 5.0.1

Userful references