ICSharpCode.SharpZipLib.Zip.ZipExtraData.ReadShort C# (CSharp) Method

ReadShort() public method

Read a short value in little endian form from the last found data value.
public ReadShort ( ) : int
return int
        public int ReadShort() {
            ReadCheck(2);
            int result=_data[_index]+(_data[_index+1]<<8);
            _index+=2;
            return result;
        }

Usage Example

示例#1
0
 // For AES the method in the entry is 99, and the real compression method is in the extradata
 //
 private void ProcessAESExtraData(ZipExtraData extraData)
 {
     if (extraData.Find(0x9901))
     {
         // Set version and flag for Zipfile.CreateAndInitDecryptionStream
         versionToExtract = ZipConstants.VERSION_AES;                            // Ver 5.1 = AES see "Version" getter
         // Set StrongEncryption flag for ZipFile.CreateAndInitDecryptionStream
         Flags = Flags | (int)GeneralBitFlags.StrongEncryption;
         //
         // Unpack AES extra data field see http://www.winzip.com/aes_info.htm
         int length = extraData.ValueLength;                         // Data size currently 7
         if (length < 7)
         {
             throw new ZipException("AES Extra Data Length " + length + " invalid.");
         }
         int ver            = extraData.ReadShort();                 // Version number (1=AE-1 2=AE-2)
         int vendorId       = extraData.ReadShort();                 // 2-character vendor ID 0x4541 = "AE"
         int encrStrength   = extraData.ReadByte();                  // encryption strength 1 = 128 2 = 192 3 = 256
         int actualCompress = extraData.ReadShort();                 // The actual compression method used to compress the file
         _aesVer = ver;
         _aesEncryptionStrength = encrStrength;
         method = (CompressionMethod)actualCompress;
     }
     else
     {
         throw new ZipException("AES Extra Data missing");
     }
 }
All Usage Examples Of ICSharpCode.SharpZipLib.Zip.ZipExtraData::ReadShort