Click here to Skip to main content
15,886,110 members
Articles / Programming Languages / Java

Encrypted Zipping of Files in C# and Java

Rate me:
Please Sign up or sign in to vote.
4.47/5 (9 votes)
14 Sep 2008CPOL3 min read 75.1K   5.3K   55  
Source code to create a compressed, encrypted password protected zip file in C# and Java
using System;
using System.Collections.Generic;
using System.Text;

namespace ZipFramework
{
    public class DataDescriptor : DataHeaderBase
    {
        private const UInt32 DATA_DESC_HEADER = 0x08074b50;

        /// <summary>
        /// Default constructor does nothing
        /// </summary>
        public DataDescriptor(FileEntry Parent):base(Parent)
        {

        }
        
        /// <summary>
        /// The signature of the Data descriptor
        /// </summary>
        public override UInt32 Signature
        {
            get
            {
                return DATA_DESC_HEADER;
            }
        }

        /// <summary>
        /// Returns a Byte array representing all of this object
        /// </summary>
        /// <returns>A byte array</returns>
        protected internal override byte[] GetOutput()
        {
            List<byte> bytes = new List<byte>();
            bytes.AddRange(BitConverter.GetBytes(this.Signature));
            bytes.AddRange(BitConverter.GetBytes(this.CRC32));
            bytes.AddRange(BitConverter.GetBytes(this.CompressedSize));
            bytes.AddRange(BitConverter.GetBytes(this.UnCompressedSize));

            return bytes.ToArray();

        }

    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Junior)
United Kingdom United Kingdom
I am an iSeries Synon/RPG programmer, who likes to program in C# and Java in my spare time.

Comments and Discussions