Home Forums .NET libraries Xceed Zip & Real-Time Zip for .NET Windows Phone 8 Sample

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #20534 |

    Do you have a version of this :-

    http://doc.xceedsoft.com/products/XceedZipSilverlight/#topic20.html

    for WP8 that can also encrypt with AES and be read\opened by WinZip ?

    Thanks

     

    Dave

     

    Imported from legacy forums. Posted by Dave (had 879 views)

    Diane [Xceed]
    Moderator
    Post count: 1353

    Hi Dave,

    Here is the feedback I received from the lead developer:

    The code will be the same except that you will supply your own Stream objects since there is likely no FileStream on WindowsPhone.

    To enable AES encryption, you need to set the encryption method and supply a password to each item you wish to encrypt in the archive.

    For example:

      localHeader.EncryptionMethod = EncryptionMethod.WinZipAes;
      localHeader.EncryptionPassword = “password”;

    Below is a C# example that puts the encryption to use. You’ll have to modify the code to provide your own stream objects for input and output:

      using Xceed.Zip;
      using Xceed.Zip.ReaderWriter;

      static void ZipWriterExample()
      {
        // TODO: In WindowsPhone, there is likely no FileStream class. You’ll have to supply your own stream object
        using( Stream zipFileStream = new YourTypeOfStream() )
        {
          /* Wrapping the ZipWriter object in a ‘using’ block will make sure the archive is closed
          * properly after we’re done adding content. If you use ZipWriter outside a ‘using’ block,
          * make sure you call ZipWriter.CloseZipFile() to flush the archive’s meta data
          * to the output stream. */

          // Create the ZipWriter object around the stream
          using( ZipWriter zipWriter = new ZipWriter( zipFileStream ) )
          {
            // Create a local header object
            ZipItemLocalHeader localHeader = new ZipItemLocalHeader();

            /* Since we’ll be adding many files in the archive, we’ll create a work buffer
              * ahead of time and use it over and over again to avoid creating a new buffer
              * to read each time we read a source file. */
            // Create a 256KB work buffer that will be used in the loop
            byte[] buffer = new byte[ 256 * 1024 ];

            // TODO: Go over each file you want to zip
            foreach( /* Files you want to zip*/ )
            {
              // TODO: Set the name of the current file in the local header
              localHeader.FileName = YourFileName;

              /* This enables AES encryption for the item */
              localHeader.EncryptionMethod = EncryptionMethod.WinZipAes;
              localHeader.EncryptionPassword = “password”;
           
              // Write the local header for the file in the archive
              zipWriter.WriteItemLocalHeader( localHeader );

              // TODO: Open the current file for reading
              using( Stream fileStream = YourTypeOfStream( YourCurrentFile ) )
              {
                // Write the entire stream’s content to the archive, using the work buffer we created
                zipWriter.WriteItemData( fileStream, buffer, 0, buffer.Length );
              }
            }
          }
        }
      }

    Imported from legacy forums. Posted by Diane [Xceed] (had 659 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.