Search code examples
c#.netfilearchive

File archiving library/API?


I'm making an application where a document is going to depend on resources and I want them to be embeded into one file. Instead of creating a new format, I was wondering if there was a library or API that already exists to create files with other files embeded in them. It doesn't matter what format it is but I'm looking for one with:

  1. OPTION to encrypt or not encrypt
  2. Can tell wether an existing file is already encrypted or not.
  3. Let's me make my own file extension for it, instead of using one that was created for the format.
  4. Works with .NET 3.5

Are there any libs that you guys would recommend?


Solution

  • I'm not sure what you mean by "creating your own format".

    There are many ways to archive/encrypt files. You can combine these methods. First encrypt whatever you want to write, and then use an API to write them.

    Here are a few resources to create archives:

    http://weblogs.asp.net/jgalloway/archive/2007/10/25/creating-zip-archives-in-net-without-an-external-library-like-sharpziplib.aspx

    For encryption you can use RSA. Replace your_rsa_key with your RSA key.

    var provider = new System.Security.Cryptography.RSACryptoServiceProvider();
    provider.ImportParameters(your_rsa_key);
    
    var encryptedBytes = provider.Encrypt(
        System.Text.Encoding.UTF8.GetBytes("Hello World!"), true);
    
    string decryptedTest = System.Text.Encoding.UTF8.GetString(
        provider.Decrypt(encryptedBytes, true));