summaryrefslogtreecommitdiff
path: root/lib/crypto/RollingChecksum.cpp
diff options
context:
space:
mode:
authorBen Summers <ben@fluffy.co.uk>2005-10-14 08:50:54 +0000
committerBen Summers <ben@fluffy.co.uk>2005-10-14 08:50:54 +0000
commit99f8ce096bc5569adbfea1911dbcda24c28d8d8b (patch)
tree049c302161fea1f2f6223e1e8f3c40d9e8aadc8b /lib/crypto/RollingChecksum.cpp
Box Backup 0.09 with a few tweeks
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;
+ }
+}
+
+
+