How use the LZMA SDK (7Zip)

How extend the LZMA with C/C++ and implement customized softwares using the 7Zip library.

First of all, what is LZMA SDK?

LZMA SDK is a package with all you need to extend and developing your own application without recreate the wheel!
It is complete with documentation, samples, interfaces, libraries and tools to help in the use of compaction  algorithm LZMA in custom applications.

What languages are supported by the LZMA SDK?
The SDK supports the following languages C, C++, C# and Java. [+]

Licence

How the own site said, "LZMA SDK is placed in the public domain." and goes beyond "Anyone is free to copy, modify, publish, use, compile, sell, or distribute the original LZMA SDK code, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means."
I understand, that you can use library for commercial or non commercial purpose, without restrictions.

Enviroment of development

I will use Microsoft Visual Studio 2010 and SDK downloaded from official site [lzma].

The chalenge

Understand how load the SDK and do the calls to generate a content compressed and encrypted.

Worries

Worried with SDK quality, facility to extend (understand) and lack of support. I am open source projects fan and the strength of some communities is admirable, however some amazing tools don't have a big market penetration, therefore don't form an experienced, big and active community.

Scope

Despite the non-functional scope has been very clear, functional yet remained with gaps to fill, because the first information was would be a file with the extension ".7z" and AES encryption. After a few conversations and coffees came to the following scope:

  • Create an executable to promote only the extraction of files generated by 7Zip;
  • The cryptographic cipher will be (AES);
  • Keep attention with memory consumed, because will be used files with a big data volume;
  • Prevent "man in the middle".

The imersion

I created a new project in my RAD, extract all content from the zip package (LZMA SDK) and I started searching for examples or utilities that show how to use the SDK. Here fit a philosophical pause: "I believe that evaluate the someone code's can show a little bit how this developer think. It is like visit and know the someone house's", so this reflection is valid : Attention with your code, after all no one like to visit a dirty and messy place.
It was a great surprise learn this SDK, with a highest quality of code and an organized structure of SDK, it helped for soon already be able to do some examples and start to understand the logical of tool.

Doubts! 

In normal cases of temperature and pressure is hard develop, compile, test and all things worked in the first try and this project didn't escape from the rule. After some attempts I see myself blocked and without alternatives, so I decided to  post my doubt in the main channel, the project forum on SourceForge (7Zip - SourceForge) The great surprise was to know that the forum works and the owner of 7Zip is very solicitous and an active member. So if you have doubt don't think twice in share on forum, but first don't forget to do a search by your topic, this can be a common topic.

SDK

The structure is divided by programming language and is all set to be imported by your favorite RAD, by the way you can agile the begin of development.
















Examples and Utilities

While I was looking for on web I found many examples using language C, the same can be found on the path (\C\Util\Lzma) and the filename is LzmaUtil.c:


Example source code:
















How was defined in the scope, I need to do the unzip and decrypt, but how the code developed in C didn't has the needed features, I was looking for an alternative and on the forum someone told me to use the code developed with CPP and most specified the Client7z.cpp:

















Here the example of SDK unzipped and imported to my RAD:




















Example source code:








Conclusion

The SDK (LZMA) of tool 7Zip is an awesome alternative for zip and cryptography, a source code with high quality, great documentation and a community active. You can increase the speed of your projects with focus on details and customization of your solution and don't need waste time in recreating the wheel.
When will think in the architecture of solution, you need to know all features such the graphic interface and shell commands, keep focus only in customize the unzip and decrypt.

Comentários

Postagens mais visitadas deste blog

How config Maven to work with NTLM proxy

Como utilizar a LZMA SDK (7Zip)