![]()
Long back, I own a Cyrix machine and periodically it stops booting by showing the message – “Checksum failure“. I still remember those long beeps.
Well, Checksum is digest generated from a long data which can be used to check the integrity of data.

For instance, if you want to know whether your data file is corrupted, generate and keep the checksum and afterwards for verification again generate the checksum and compare. So how to generate the checksum?
![]()
You can use the function – CheckSumMappedFile(). Actually its used to calculate the checksum of mapped file. Well, you can use it to calculate the checksum of your data too! Just see the code snippet.
// The data.
char* pString = "Hello";
DWORD HeaderSum = 0;
DWORD Checksum = 0;
// Calculate the checksum.
CheckSumMappedFile( pString,
strlen( pString),
&HeaderSum,
&Checksum );
![]()
The return of the function is PIMAGE_NT_HEADERS and in this case, it will be 0 and just ignore it. Since our data provided is not a valid PE file, its obvious. If you check the Checksum variable, you can find it contains a valid checksum always. So Take care!
![]()
Targeted Audience – Intermediate.



Hi Raj,
I was surfing for checksum generation and was wondering if you could help
Basically I need to decipher the pattern needed to convert a 10 digit number into a checksum.
Any Ideas or any utility that exists that you know off would be helpful
Thanks
Hilario
Hello Hilario,
If my understand is correct, you want to generate the checksum of a 10 digit number, isn’t it?
Well, just convert the integer to string and call CheckSumMappedFile(). You could do it by C++ functions such as itoa(), CString::Format() etc etc. Check out this link – http://www.cplusplus.com/reference/clibrary/cstdlib/itoa.html. Once you convert your number to string then the rest is easy – just call CheckSumMappedFile().
Does this helps? Feel free to ask for further help. I’m always glad to do so.
Regards,
Jijo.
will the same way i will calculate a checksum of a some file like .exe or.dex(android executable)????????