diff options
author | zyp <zyp@localhost> | 2006-10-27 13:30:01 +0200 |
---|---|---|
committer | zyp <zyp@localhost> | 2006-10-27 13:30:01 +0200 |
commit | e7372290e93e2fa26237e2ecbe257c8ccc4dce30 (patch) | |
tree | 5e5e1bff5b9f3191e0dea2d7bdc9a55a82345542 /hash/ed2k.cpp | |
parent | 802668818e930d91c37f8107e4c8822bd3ebdfac (diff) |
[project @ zyp-20061027113001-b3ca581e0efa4fa6]
[project @ 65]
This should not be here.
Diffstat (limited to 'hash/ed2k.cpp')
-rw-r--r-- | hash/ed2k.cpp | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/hash/ed2k.cpp b/hash/ed2k.cpp deleted file mode 100644 index 92e7b15..0000000 --- a/hash/ed2k.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "ed2k.h" - -template<class T> -inline T min(T a, T b) { - return (a > b) ? b : a; -} - -Ed2k::Ed2k() { - MD4_Init(&md4_partial); - MD4_Init(&md4_final); - size_total = 0; -} - -void Ed2k::update(const char* data, int length) { - while(length) { - if(!(size_total % (9500 * 1024)) && size_total) { - unsigned char digest[16]; - MD4_Final(digest, &md4_partial); - MD4_Update(&md4_final, digest, 16); - MD4_Init(&md4_partial); - } - int size = min<int>(length, (9500 * 1024) - (size_total % (9500 * 1024))); - MD4_Update(&md4_partial, data, size); - length -= size; - data += size; - size_total += size; - }; -} - -char* Ed2k::digest() { - char* digest = new char[16]; - if(size_total > (9500 * 1024)) { - unsigned char digest_partial[16]; - MD4_Final(digest_partial, &md4_partial); - MD4_Update(&md4_final, digest_partial, 16); - MD4_Final((unsigned char*)digest, &md4_final); - } else { - MD4_Final((unsigned char*)digest, &md4_partial); - } - return digest; -} |