summaryrefslogtreecommitdiff
path: root/ed2k.cpp
diff options
context:
space:
mode:
authorzyp <zyp@localhost>2006-05-08 15:23:20 +0200
committerzyp <zyp@localhost>2006-05-08 15:23:20 +0200
commitdf9c15d40a50ed17baa7bdbb11ef6cca9d410cf3 (patch)
tree4ceb64d5c29e6bf487f8a6e7dde655a2c0b5f26a /ed2k.cpp
parent3a5b32f44a95b989e39273527fc924ad3d32465e (diff)
[project @ zyp-20060508132320-2c118d1a7e2505db]
[project @ 24] Converted from make to distutils.
Diffstat (limited to 'ed2k.cpp')
-rw-r--r--ed2k.cpp41
1 files changed, 0 insertions, 41 deletions
diff --git a/ed2k.cpp b/ed2k.cpp
deleted file mode 100644
index 92e7b15..0000000
--- a/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;
-}