summaryrefslogtreecommitdiff
path: root/lib/crypto/RollingChecksum.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/crypto/RollingChecksum.cpp')
-rwxr-xr-xlib/crypto/RollingChecksum.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/crypto/RollingChecksum.cpp b/lib/crypto/RollingChecksum.cpp
new file mode 100755
index 00000000..75bad7df
--- /dev/null
+++ b/lib/crypto/RollingChecksum.cpp
@@ -0,0 +1,38 @@
+// --------------------------------------------------------------------------
+//
+// File
+// Name: RollingChecksum.cpp
+// Purpose: A simple rolling checksum over a block of data
+// Created: 6/12/03
+//
+// --------------------------------------------------------------------------
+
+#include "Box.h"
+#include "RollingChecksum.h"
+
+#include "MemLeakFindOn.h"
+
+// --------------------------------------------------------------------------
+//
+// Function
+// Name: RollingChecksum::RollingChecksum(const void *, unsigned int)
+// Purpose: Constructor -- does initial computation of the checksum.
+// Created: 6/12/03
+//
+// --------------------------------------------------------------------------
+RollingChecksum::RollingChecksum(const void *data, unsigned int Length)
+ : a(0),
+ b(0)
+{
+ uint8_t *block = (uint8_t *)data;
+ for(unsigned int x = Length; x >= 1; --x)
+ {
+ a += (*block);
+ b += x * (*block);
+
+ ++block;
+ }
+}
+
+
+