ZWinCrypt - C++ Library for Hashing, Encryption and Compression

Copyright (C) Werner Zimmermann (wernerzimmermann.name)


Overview

This C++ library provides a wrapper around some crypto algorithms, to hash, encrypt/decrypt or compress/uncompress memory blocks and files. Hashing algorithms include MD5, SHA1 and SHA2. Encrypting/decrypting is supported using AES/Rijdael and Blowfish algorithms. Compression/uncompression is done using Lempel-Ziv, Run-Length-Encoding and Huffman. These algorithms have not been implemented from scratch but have been copied (in modified form) from various sources. For details see section 'Disclaimer' in this file and subdirectory ./crypt.

ZWinCrypt can be used together with my GUI library ZWinLib, my XML wrapper library ZWinXml and/or my SQL file database library ZWinSql or it can be used stand alone.

Please also have a look at ZWinCrypts's close friends ZWinXml for XML document handling, ZWinLib for graphical user interfaces and ZWinSql for SQL file databases, also available on the same web site.


Installation

This library is distributed as a zip file. To install, unzip it into your desired installation directory. You'll get the following directory structure:

To run one of the samples, go to the samples subdirectory and run the respective Sample...exe file. To recompile one of the samples, in a console window change to the sample's directory and type 'nmake'. This assumes, that Visual C++ compiler, linker, resource editor and (n)make utility are available in the path of your console window.

If you need to recompile the library itself, in a console window change to the src directory and type 'nmake'.

To develop your own ZWinCrypt applications, create another subdirectory in the samples directory, copy the files from Sample31 or Sample32 into this new subdirectory and start modifying these files. (Don't forget to modify the makefile, too!)

If you ever want to deinstall ZWinCrypt again (why should you? :--)) ) simply delete the installation directory and all its subdirectories. ZWinCrypt does not copy files into any other directory nor does it touch the registry.


Getting started

The ZWinCrypt library provides the following user relevant classes:

Using ZwinCrypt to compress, encrypt and hash a file is as simple as:

#include "ZWinCrypt.h"                 //ZWinCrypt header file

//***** Compress a file *****
WCompress *pC = new WCompress();       //Default algorithm Lempel-Ziv)
pC->CompressFile("yourInputFile", "yourCompressedFile");

//***** Encrypt the file *****
WCrypt *pF= new WCrypt();              //Default algorithm Blowfish
pF->EncryptFile("yourCompressedFile", "yourEncryptedFile", "yourPassword");

//***** Hash the file (hash copied to yourHash, lenght returned in N) *****                                       
WHash *pH = new WHash();               //Default algorithm SHA1 (20 byte = 160 bit hash)
BYTE yourHash[20];                     
int N;
pH->HashFile("yourEncryptedFile", yourHash); 
        
Decrypting and uncompressing is not more complicated:
//***** Decrypt a file *****
pF->DecryptFile("yourEncryptedFile", "yourUnencryptedFile", "yourPassword");

//***** Decompress a file *****
pC->DecompressFile("yourUnencryptedFile", "yourUncompressedFile");
        
At the end of this sequence, the contents of yourUncompressedFile should be equal to yourInputFile.

To get more detailed usage information, have a look at the examples below and look into the detailed functional documentation in file "ZWinCrypt.chm" (generated by Doxygen from ZWinCrypt.h, included in ZWinCrypt's doc subdirectory).


Examples

The package comes with some example files:

More samples and additional programming tips may be added in later versions.


ZWinCrypt compatibility

ZWinCrypt was developed and tested with Microsoft Visual C++ 2003 ... 2017 (English version) and tested under Windows XP/7/10. Other versions of Visual C++ and Windows should work, but have not been tested.


Release Notes

V0.1.0: First public beta release.
V0.2.0: Added support for RSA public key cryptography.
V0.3.0: Diffie-Hellman based session key generation, secure socket communication and ECC public key cryptography.


Disclaimer and copyright information

All files are provided in the hope, they might be useful, but without any warranty or support. You may use or modify them on your own risk in non-commercial applications. Even if ZWinCrypt is provided free of charge, it is no freeware. It is copyrighted by Werner Zimmermann.

Even if none of the algorithms is patented (as far as the author knows), the implementation uses code fragments from other people (especially George Anescu, Dominik Reichl, Marcus Geelnard, George Barwood, Bruce Scheider), which have their own copyright statements. See subdirectory ./crypt for details. Thank you guys!

Windows, Visual C++, Visual Studio and other product names mentioned here may be trademarks or registered trademarks of their respective owners.


Programming tips

Sorry, none yet ...


(C) wernerzimmermann.name