1 Screenshot
2 Source code
/*
* SHA.cpp
* Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED.
*/
// 2009/02/22
// 2009/02/23 Added the case CALG_SHA_384
#include <sol/crypt/CryptServiceProvider.h>
#include <sol/crypt/MessageDigest.h>
void _tmain(int argc, TCHAR** argv)
{
if (argc != 2) {
printf("Usage:SHA.exe filePath\n");
return;
}
try {
CryptServiceProvider csp;
{
printf("\n");
printf("SHA1\n");
MessageDigest md(csp, CALG_SHA1);
md.hashFile(argv[1]);
Bytes bytes;
md.getHashValue(bytes);
bytes.dump();
}
{
printf("\n");
printf("SHA256\n");
MessageDigest md(csp, CALG_SHA_256);
md.hashFile(argv[1]);
Bytes bytes;
md.getHashValue(bytes);
bytes.dump();
}
{
printf("\n");
printf("SHA384\n");
MessageDigest md(csp, CALG_SHA_384);
md.hashFile(argv[1]);
Bytes bytes;
md.getHashValue(bytes);
bytes.dump();
}
{
printf("\n");
printf("SHA512\n");
MessageDigest md(csp, CALG_SHA_512);
md.hashFile(argv[1]);
Bytes bytes;
md.getHashValue(bytes);
bytes.dump();
}
} catch (Exception& ex) {
printf("Exception = %s\n", ex.getErrorMessage());
}
}
Last modified: 2 May 2016
Copyright (c) 2016 Antillia.com ALL RIGHTS RESERVED.