SOL9 2.0 Sample: MD5

SOL9 2.0 Samples

1 Screenshot


2 Source code

/*
 * MD5.cpp 
 * Copyright (c) 2009 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */


// 2009/02/23 Added the cases for MD2, MD4

#include <sol/crypt/CryptServiceProvider.h>
#include <sol/crypt/MessageDigest.h>


int _tmain(int argc, TCHAR** argv)
{
    int rc = 0;
    if (argc != 2) {
        printf("Usage:MD5.exe filePath\n");
        return rc;
    }

    try {

        CryptServiceProvider csp;
        {
            MessageDigest md(csp, CALG_MD2);

            md.hashFile(argv[1]);

            Bytes bytes;
            md.getHashValue(bytes);

            printf("MD2:\n");
            bytes.dump();
        }
        {
            MessageDigest md(csp, CALG_MD4);

            md.hashFile(argv[1]);

            Bytes bytes;
            md.getHashValue(bytes);

            printf("MD4:\n");
            bytes.dump();
        }

        {
            MessageDigest md(csp, CALG_MD5);

            md.hashFile(argv[1]);

            Bytes bytes;
            md.getHashValue(bytes);

            printf("MD5:\n");
            bytes.dump();
        }

    } catch (Exception& ex) {
        printf("Exception = %s\n", ex.getErrorMessage());
    }

    rc = GetLastError();

    return rc;
}

Last modified: 11 Nov 2009

Copyright (c) 2009 Antillia.com ALL RIGHTS RESERVED.