SOL9 2.0 Sample: MAC

SOL9 2.0 Samples

1 Screenshot


2 Source code

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


//2009/02/22

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


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

    try {

        CryptServiceProvider csp;

        KeyedMessageDigest mac(csp, CALG_MAC);

        mac.hashFile(argv[1]);

        Bytes bytes;
        mac.getHashValue(bytes);
 
        printf("MAC:\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.