I’ve been working on Korama. I was originally planning on hashing each music file and using the sha1 for the track primary key. However, after benchmarking an actual implementation. I’ve decided that it’s too slow, 20 minutes for 3k+ tracks, also my program was about 5 minutes slower than
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;
CryptoPP::FileSource( ( file ),true,
hash, new CryptoPP::HexEncoder(
new CryptoPP::StringSink(result), false)
cout << result << endl;
it can be built with.
g++ sha1.cpp -lcryptopp -o sha1sum
and tested with
It’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.