Ridavei.FileCryption 1.0.2.3

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

// Install Ridavei.FileCryption as a Cake Tool
#tool nuget:?package=Ridavei.FileCryption&version=1.0.2.3

Ridavei.FileCryption

What is FileCryption?

Ridavei.FileCryption is a cross-platform library created to ease file decryption/encryption.

Examples in using FileCryption

File decryption

using System.IO;
using System.Net.Mime;

using Ridavei.FileCryption;

namespace TestProgram
{
    class Program
    {
        public static void Main (string[] args)
        {
            ContentType contentType;
            object fileInfo;
            string password;
            
            /*
              Setting the variables above
            */
            using (Stream decryptedFile = FileDecryptionBuilder
                .CreateBuilder()
                .SetFileLoaderMethod((object fileInfo) =>
                {
                    //Return file as Stream
                })
                .AddDecryptionMethod(
                    contentType,
                    (Stream file, string password) =>
                {
                    //Return decrypted Stream
                })
                .Decrypt(fileInfo, contentType, password))
            {
                //Saving the file
            }
        }
    }
}
Simple file decryption
using System.IO;
using System.Net.Mime;

using Ridavei.FileCryption;

namespace TestProgram
{
    class Program
    {
        public static void Main (string[] args)
        {
            ContentType contentType;
            object fileInfo;
            string password;
            
            /*
              Setting the variables above
            */
            using (Stream decryptedFile = FileDecryptionBuilder
                .CreateBuilder()
                .SetFileLoaderMethod(FileLoaderMethod)
                .AddDecryptionMethod(contentType, DecryptionMethod)
                .Decrypt(fileInfo, contentType, password))
            {
                //Saving the file
            }
        }
        
        private static Stream FileLoaderMethod(object fileInfo)
        {
            //Return file as Stream
        }
        
        private static Stream DecryptionMethod(Stream file, string password)
        {
            //Return decrypted Stream
        }
    }
}

Creating extensions

using System.IO;
using System.Net.Mime;

using Ridavei.FileCryption;

namespace TestProgram
{
    //Extension for the base class
    public static class FileLoaderExt
    {
        public static T UseFileLoaderExt<T>(this AFileCryptionBuilderBase<T> builder) where T : AFileCryptionBuilderBase<T>
        {
            builder.SetFileLoaderMethod((object filePath) =>
            {
                return new FileStream(filePath.ToString(), FileMode.Open, FileAccess.Read, FileShare.Read);
            });
            return (T)builder;
        }
    }
    
    //Extension for the FileEncryptionBuilder class
    public static class EncryptExt
    {
        public static FileEncryptionBuilder UseEncryptTxtExt(this FileEncryptionBuilder builder)
        {
            return builder.AddEncryptionMethod(new ContentType(MediaTypeNames.Text.Plain), EncryptTxt);
        }
        
        private static Stream EncryptTxt(Stream file, string password)
        {
            //Some magic
        }
    }
}
Simple file encryption using extensions from above
using System.IO;
using System.Net.Mime;

using Ridavei.FileCryption;

namespace TestProgram
{
    class Program
    {
        public static void Main (string[] args)
        {
            ContentType contentType;
            object fileInfo;
            string password;
            
            /*
              Setting the variables above
            */
            using (Stream decryptedFile = FileEncryptionBuilder
                .CreateBuilder()
                .UseFileLoaderExt()
                .UseEncryptTxtExt()
                .Encrypt(fileInfo, contentType, password))
            {
                //Saving the file
            }
        }
    }
}

You can use many other encryption/decryption methods because they are added into a Dictionary. If you add a encryption/decryption method for a ContentType that already exists in the Dictionary it will overwrite the last one.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  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. 
.NET Framework net35 is compatible.  net40 was computed.  net403 was computed.  net45 was computed.  net451 was computed.  net452 is compatible.  net46 was computed.  net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 is compatible.  net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 3.1

    • No dependencies.
  • .NETFramework 3.5

    • No dependencies.
  • .NETFramework 4.5.2

    • No dependencies.
  • .NETFramework 4.6.2

    • No dependencies.
  • .NETFramework 4.7.2

    • No dependencies.
  • .NETFramework 4.8

    • No dependencies.
  • net5.0

    • No dependencies.
  • net6.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Ridavei.FileCryption:

Package Downloads
Ridavei.FileCryption.Loader.FileStream

Builder extension for loading file through FileStream for file decryption/encryption.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.2.3 421 5/13/2022
1.0.2.2 574 5/12/2022
1.0.2.1 585 5/5/2022
1.0.2 606 5/5/2022