CryptDecode with modifier CRYPT_ARCH_ZIP - How to use? - page 4

 
sanyooooook:
Well, it does, and then it compares it to the output of the regular archiver

So what's the problem?

If the ZIP createdby CryptEncode() is decoded, isn't it clear what the problem is?

 

MQ has its own format!

   string file_name = "GAZR-6.15.dat";
   uchar array[];
   uchar key[];
   uchar result[];
   int a_handle = FileOpen( file_name, FILE_READ|FILE_BIN );
   if ( a_handle != INVALID_HANDLE )
   {
     uint array_size = FileReadArray( a_handle, array );
     if ( array_size > 0 )
     {
       ArrayResize( key, array_size );
       for ( int i = 0; i < int( array_size ); i++ ) key[i] = 0;
       int a_enc = CryptEncode( CRYPT_ARCH_ZIP, array, key, result );
       int b_handle = FileOpen( "test.zip", FILE_WRITE|FILE_BIN );
       if ( b_handle != INVALID_HANDLE )
       {
         FileWriteArray( b_handle, result );
         FileClose( b_handle );
       }  
       FileClose( a_handle );
     }  
   }
   
   
   
   
   int handle = FileOpen( "test.zip", FILE_READ|FILE_BIN );
   if ( handle != INVALID_HANDLE )
   {
     uint array_size = FileReadArray( handle, array );
     FileClose( handle );
     
     Print( "Read totals: ", array_size );
     ArrayResize( key, array_size );
     for ( int i = 0; i < int( array_size ); i++ ) key[i] = 0;
     //ArrayResize( result, array_size, array_size * 100 );
     
     ResetLastError();
     int d = CryptDecode( CRYPT_ARCH_ZIP, array, key, result );
   
    if ( d < 1 )
     {
       Print( GetLastError() );
     } 
   }

Everything works if you create an archive from MQL5

But this archive is not unpackable with standard ZIP!!!

 
Mikalas:

MQ has its own format!

Everything works if you create an archive from MQL5

But this archive is not unpacked with standard ZIP!!!

Michael, read Aleksander's post carefully:

sanyooooook:

ZIP archive is a whole structure, the function archives/unarchives an array, i.e. you should only put there an array that is ready to be de-archived.

Roughly speaking, it unarchives only the output of the archiving function.


I.e. there is no native format from MQ. Just what the CryptEncode function gives you is just a part of the zip archive, the rest you have to create yourself. But the problem is that not even parts of archives between standard zip archiver and CryptEncode match.

Anyway, waiting for Monday. Only MQ can give us the information we are missing.

 
C-4:

Mikhail, read Alexander's post carefully:


So there is no proprietary format from MQ. Just what the CryptEncode function gives you is just a part of the zip archive, the rest you have to create yourself. But the problem is that not even parts of archives between standard zip archiver and CryptEncode match.

Anyway, we are waiting for Monday. Only MQ can give us the information we are missing.

So skip the Header and read only the data!

Google it = PKWare data compression library header

 
Mikalas:

So what's the problem?

If the ZIP createdby CryptEncode() decodes, isn't it clear what the problem is?

The structure of what comes after CryptoDecode and what comes after the regular archiver is different
 

here are some experiments I've done:

in the file: The quick brown fox jumps over the lazy dogThe quick brown fox jumps over the lazy dog

in file: The quick brown fox jumps over the lazy dog

on file: sdfgghghjdfggfghjghghghjk,g

 
it turns out that MQ has its own output structure.
 

Vasiliy!

MQL5 creates a ZIP without a header!

Consequently, it does not skip it when reading.

Googling = PKWare data compression library header

http://en.wikipedia.org/wiki/Zip_(file_format)

MQ has only one compression method, so

if a ZIP is using a different compression method, you will not be able to decompress it.

I.e. not all ZIP archives will be available to you!

 
sanyooooook:
MQ has its own output structure.

It cannot be "its own", otherwise it has nothing to do with ZIP at all.

The structures of the packed data will differ depending on the compression ratio, they cannot NOT differ. Consequently, CryptDecode must be somehow managed by a key which describes the particular compression ratio and other necessary parameters. Only MQ knows how to properly configure the key.

Mikalas:

Vasiliy!

MQL5 creates a ZIP without a header!

Mikhail, you need to understand what you are talking about. The problem is not with the header or the file format. Carefully read this article.

 
C-4:

It cannot be "its own", otherwise it has nothing to do with ZIP at all.

The structures of the packed data will differ depending on the compression ratio, they cannot NOT differ. Consequently, CryptDecode must be somehow managed by a key which describes the specific compression ratio and other parameters. Only MQ knows how to properly configure the key.

Mikhail, you need to understand what the problem is. The problem is not with the header or the file format. Read the thread carefully.

Then correctly state what you want.

At the beginning of your thread you have the code.

You read the archive in its entirety and you are trying to decode it along with the header!

Any ZIP archive, created with a standard packer, has a HEADER!

MQL5 unpacker does NOT skip header.

Therefore, you cannot unpack data.

So, explain:

Initially, what do you want?