Click here to Skip to main content
12,297,854 members (47,393 online)
Click here to Skip to main content

Stats

177.9K views
4.9K downloads
113 bookmarked
Posted

A File Checksum Shell Menu Extension DLL

, 23 May 2008 LGPL3
Create a File Checksum Shell Menu Extension using ATL and Crypto++
CtxCreateHash
CtxCreateHash
CreateHash.rgs
CtxCreateHash.def
CtxCreateHash.rgs
CtxCreateHash.vcproj.8.00.old
CtxCreateHashps.def
CtxCreateHashPS.vcproj.8.00.old
CtxCreateHash.sln.old
CreateHash.rgs
CtxCreateHash.aps
CtxCreateHash.def
CtxCreateHash.rgs
CtxCreateHashps.def
CtxCreateHash.dll
CtxVerifyHash
CtxVerifyHash
CtxVerifyHash.def
CtxVerifyHash.rgs
CtxVerifyHash.vcproj.8.00.old
CtxVerifyHashps.def
CtxVerifyHashPS.vcproj.8.00.old
VerifyHash.rgs
CtxVerifyHash.sln.old
CtxVerifyHash.aps
CtxVerifyHash.def
CtxVerifyHash.rgs
CtxVerifyHashps.def
VerifyHash.rgs
CtxVerifyHash.dll
Sample 1
Test 1.dsp
Test 1.dsw
Sample 2
Test 2.dsp
Test 2.dsw
Sample 3
Test 3.dsp
Test 3.dsw
Sample 4
Test 4.dsp
Test 4.dsw
Sample 5
CtxTest.def
CtxTest.dsp
CtxTest.dsw
CtxTestps.def
CtxTestps.mk
MenuItem.rgs
#include "stdafx.h"

#include "profiler.h"

#include "files.h"      // FileSource
#include "channels.h"   // ChannelSwitch
#include "filters.h"    // HashFilter

#include "hex.h"        // HexEncoder/HexDecoder

#include "md5.h"        // MD5
#include "sha.h"        // SHA-1, SHA-224, SHA-256
#include "ripemd.h"     // RIPEMD-160

using namespace CryptoPP;

int main(int argc, char* argv[])
{
    // string s( 987 * 1024 , ' ');           // Create a blanks.
    string s = "Benjamin Franklin said, They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.";

    MD5  hashMD5;
    HashFilter filterMD5(hashMD5);

    SHA1 hashSHA1;
    HashFilter filterSHA1(hashSHA1);

    RIPEMD160 hashRIPEMD160;
    HashFilter filterRIPEMD160(hashRIPEMD160);

    SHA224 hashSHA224;
    HashFilter filterSHA224(hashSHA224);
    
    SHA256 hashSHA256;
    HashFilter filterSHA256(hashSHA256);    

    std::auto_ptr<ChannelSwitch> channelSwitch(new ChannelSwitch); 
    channelSwitch->AddDefaultRoute(filterMD5);
    channelSwitch->AddDefaultRoute(filterSHA1);
    channelSwitch->AddDefaultRoute(filterRIPEMD160);
    channelSwitch->AddDefaultRoute(filterSHA224);
    channelSwitch->AddDefaultRoute(filterSHA256);

    {
        CProfiler profiler;
        __int64 ptime;
        profiler.ProfileStart( );

        // Crypto++ 5.2.1 source file is 987 kB
        // FileSource( "c:\\cryptopp521.zip", true, channelSwitch.release());
        
        StringSource( s /* 987Kb */, true, channelSwitch.release());

        // StringSource( "abcdefghijklmnopqrstuvwxyz", true, channelSwitch.release());

        ptime = profiler.ProfileEnd();    
        _tcout << _T("Channel Pump Time: ");
        _tcout << profiler.SecsFromTicks( ptime );
        _tcout << _T(" seconds") << std::endl << endl;
    }

    std::cout << "String:" << std::endl << s << std::endl << std::endl;

    string digest;
    HexEncoder encoder( new StringSink( digest ), true /* uppercase */ ); 

    filterMD5.TransferTo( encoder );
    cout << filterMD5.AlgorithmName() << ": " << digest << endl;
    digest.erase();
    
    filterSHA1.TransferTo( encoder );
    cout << filterSHA1.AlgorithmName() << ": " << digest << endl;
    digest.erase();

    filterRIPEMD160.TransferTo( encoder );
    cout << filterRIPEMD160.AlgorithmName() << ": " << digest << endl;
    digest.erase();

    filterSHA224.TransferTo( encoder );
    cout << filterSHA224.AlgorithmName() << ": " << digest << endl;
    digest.erase();
    
    filterSHA256.TransferTo( encoder );
    cout << filterSHA256.AlgorithmName() << ": " << digest << endl;
    digest.erase();    

    return 0;
}

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 GNU Lesser General Public License (LGPLv3)

Share

About the Author

Jeffrey Walton
Systems / Hardware Administrator
United States United States
No Biography provided

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160525.2 | Last Updated 24 May 2008
Article Copyright 2006 by Jeffrey Walton
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid