Sep 22, 2009

Quick sha1sum with Crypto++

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[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 sha1sum

and tested with

./sha1sum filename
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.

Sep 5, 2009

FSDaily security fail (see image)

Hint, Hint! FSDaily don't access your db with the root account. and definitely make sure that, that error page doesn't show that to users.