#include "stdafx.h" #include "Checksum.h" /**************************************************************************** * checksum::add * Inputs: * DWORD d: word to add * Result: void * * Effect: * Adds the bytes of the DWORD to the checksum ****************************************************************************/ void checksum::add(DWORD value) { union { DWORD value; BYTE bytes[4]; } data; data.value = value; for(UINT i = 0; i < sizeof(data.bytes); i++) add(data.bytes[i]); } // checksum::add(DWORD) /**************************************************************************** * checksum::add * Inputs: * WORD value: * Result: void * * Effect: * Adds the bytes of the WORD value to the checksum ****************************************************************************/ void checksum::add(WORD value) { union { DWORD value; BYTE bytes[2]; } data; data.value = value; for(UINT i = 0; i < sizeof(data.bytes); i++) add(data.bytes[i]); } // checksum::add(WORD) /**************************************************************************** * checksum::add * Inputs: * BYTE value: * Result: void * * Effect: * Adds the byte to the checksum ****************************************************************************/ void checksum::add(BYTE value) { BYTE cipher = (value ^ (r >> 8)); r = (cipher + r) * c1 + c2; sum += cipher; } // checksum::add(BYTE)
/**************************************************************************** * checksum::add * Inputs: * const CString & s: String to add * Result: void * * Effect: * Adds each character of the string to the checksum ****************************************************************************/ void checksum::add(const CString & s) { for(int i = 0; i < s.GetLength(); i++) add((BYTE)s.GetAt(i)); } // checksum::add(CString) /**************************************************************************** * checksum::add * Inputs: * LPBYTE b: pointer to byte array * UINT length: count * Result: void * * Effect: * Adds the bytes to the checksum ****************************************************************************/ void checksum::add(LPBYTE b, UINT length) { for(UINT i = 0; i < length; i++) add(b[i]); } // checksum::add(LPBYTE, UINT)
A Checksum Algorithm
- Introduction
- Checksums
- Checksum.h
- Checksum.cpp
Checksum.cpp
You might also like...
C++ books
-
C++ Primer Plus (6th Edition) (Developer's Library)
C++ Primer Plus is a carefully crafted, complete tutorial on one of the most significant and widely used programming languages today. A friendly and easy-to-use self-study guide, this book is appropriate for both serious students of programming as we...
C++ forum discussion
-
how can i in C++ send file to other PC over net ?
by greensqeq (7 replies)
-
QUERY: How to control external exe & read it's process details
by swiftsafe (2 replies)
-
Sorting parallel arrays in C
by joeyMABIA (4 replies)
-
help me with a problem anybody?
by Schleons (5 replies)
-
Logic Warz - Program your own Bot, battle other people's Bots
by Peter767 (2 replies)
C++ podcasts
-
GoingDeep: C++ and Beyond 2012: Herb Sutter - atomic<> Weapons, 2 of 2
Published 8 years ago, running time 4h1m
Herb Sutter presents atomic<> Weapons, 2 of 2. This was filmed at C++ and Beyond 2012. As the title suggests, this is a two part series (given the depth of treatment and complexity of the subject matter).STOP! => Watch part 1 first!Abstract:This session in one word: Deep.It's
C++ jobs
-
Software Developer - Edinburgh
Runtime Revolution in Edinburgh (EH2), United Kingdom
£25-40k (DOE) -
C++ Unix Developer
Flexton Inc. in San Jose, United States
-
Experienced C++ Developer
Pando Networks in New York, United States
Pando Networks offers employees a generous benefits package which includes health and dental care, short and long term disability, life insurance and retirement plans. The compensation offered for the position will commensurate with experience.
Comments