Skip to content

Common encryption and decryption logic required by various KS FIKS clients

License

Notifications You must be signed in to change notification settings

ks-no/kryptering-dotnet

Repository files navigation

kryptering-dotnet

MIT license Nuget GitHub issues

Common encryption and decryption logic required by various KS FIKS clients on the dotnet platform. All code is released under a MIT license

All crypto is performed using a portable C# version of the BouncyCastle library

Prerequisites

  • This library targets .Net Core 3.1 as well as .Net Standard 2.1
  • A PEM file containing the BASE64 encoded public certificate to be used for encryption
  • A PEM file containing the BASE64 encoded private key to be used for decryption

Example

Encryption

var encryptionService = EncryptionService.Create(/* public certificate */);
using (var encryptedOutStream = /* create out stream */)
using (var dataStream = /* the stream containing the unencrypted data */) 
{
    encryptionService.Encrypt(dataStream, encryptedOutStream);
}

Decryption

var decryptionService = DecryptionService.Create(/* private key */);
using (var encryptedDataInStream = /* stream containing the encrypted data */)
using (var decryptedOutStream = /* a stream to write the unencrypted data to */)
using (var decryptBufferStream = decryptionService.Decrypt(encryptedDataInStream))
{
    decryptBufferStream.CopyTo(decryptedOutStream);
}

About

Common encryption and decryption logic required by various KS FIKS clients

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages