find ... -exec sha1sum not sure on the reason why. However, since I had problems figuring out how to do it I figure I'll post a basic sha1sum program that I made with the help of people on the Crypto++ Mailing List.Include's are mangled due to blogger filtering
#include < cryptopp/sha.h >
#include < cryptopp/hex.h >
#include < cryptopp/files.h >
#include < string >
#include < iostream >
using namespace std;
int main(int argc, char *argv[])
{
char *file = argv[1];
string result;
CryptoPP::SHA1 hash;
CryptoPP::FileSource( ( file ),true,
new CryptoPP::HashFilter(
hash, new CryptoPP::HexEncoder(
new CryptoPP::StringSink(result), false)
)
);
cout << result << endl;
return 0;
}
it can be built with.
g++ sha1.cpp -lcryptopp -o sha1sumand tested with
./sha1sum filenameIt's not meant to be a exactly compatible implementation of sha1sum. it doesn't output the filename, it isn't capable of handling more than one file argument, and if no argument is provided it crashes. I know I haven't actually explained how the crypo++ code works, but I hope just posting this here will help someone in the future.
