From 4309066dff46f52690998bbd1f60ec8b1631f142 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 19 Feb 2009 23:44:57 +0000 Subject: We have the new Bu::CryptoHash base class and Bu::Md5 is here and ready to rock. sha1 is still only a shell, I dunno if/when I'm going to implement that one. So far Bu::Md5 is 100% compatible with md5sum in all tests performed so far, in fact the test program's output is compatible with md5sum in every way (and it's so cute and little too!) Oh, minor update for stdstream and the formatter, they can handle more handy types now. --- src/md5.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/md5.h (limited to 'src/md5.h') diff --git a/src/md5.h b/src/md5.h new file mode 100644 index 0000000..c548041 --- /dev/null +++ b/src/md5.h @@ -0,0 +1,40 @@ +#ifndef BU_MD5_H +#define BU_MD5_H + +#include "bu/cryptohash.h" + +namespace Bu +{ + /** + * Class for easily calculating MD5 sums of just about any data. + *@author Mike Buland + */ + class Md5 : public Bu::CryptoHash + { + public: + /** Build an MD5 sum builder. */ + Md5(); + + /** Deconstruct */ + virtual ~Md5(); + + virtual void reset(); + virtual void setSalt( const Bu::FString &sSalt ); + virtual void addData( const char *sData, int iSize ); + using Bu::CryptoHash::addData; + virtual FString getResult(); + + private: + /** + * Compute one block of input data. + */ + void compBlock( long *x, long *lsum ); + + long inbuf[16]; + long iFill; + long sum[4]; + uint64_t iBytes; + }; +}; + +#endif -- cgit v1.2.3