Click here to Skip to main content
15,909,437 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am writing an application(TCP/IP) that interfaces between NDC Controller and Bank Host. I want to know how to calculate the checksum(total of the characters in the message field) of the message that is sent by controller to the Bank Host.
The checksum value should be of length 10 and should be Numeric value.
In short, I would like to have a source for a checksum funtion as shown in link:
http://en.wikipedia.org/wiki/File:Checksum.svg

Please help.
Posted
Updated 12-Jun-11 23:27pm
v2

1 solution

Choose a checksum algorithm and implement it. You have enough algorithms to choose from, see http://en.wikipedia.org/wiki/Checksum[^]. See the Web referenced from this article.

You can use already implemented Cryptographic Hash Function (http://en.wikipedia.org/wiki/Cryptographic_hash_function[^]) from the name space System.Security.Cryptography, for example, use one of the classed derived from System.Security.Cryptography.HashAlgorithm each representing a Cryptographic Hash Function from the "SHA" family (see http://en.wikipedia.org/wiki/SHA-2[^]) or MD5 (http://en.wikipedia.org/wiki/MD5[^]) using the class System.Security.Cryptography.MD5.

Note: Don't use MD5 for any security purposes, as this algorithm is considered broken, see http://en.wikipedia.org/wiki/MD5[^]. For checksum purposes it is good enough though.

[EDIT]
Here I found CRC implementation:
CRC Encoding[^].
There are many others.

—SA
 
Share this answer
 
v2
Comments
RashmitaS 8-Jun-11 2:29am    
First of thanks for the suggestion. I did try SHA HashAlgorithm but it returns 40 characters. Actually i need the checksum of length 10 and the datatype should be numeric. Please suggest.
Sergey Alexandrovich Kryukov 8-Jun-11 12:54pm    
OK, you did not ask about it. There are many other variants, see the very first link. Use something simple like CRC. See my update (after [EDIT]), for example.
--SA
RashmitaS 9-Jun-11 5:35am    
Sorry if i could not make myself clear. In short, I would like to have a source for a checksum funtion as shown in link:
http://en.wikipedia.org/wiki/File:Checksum.svg
Sergey Alexandrovich Kryukov 12-Jun-11 18:28pm    
Good.
Will you formally accept my solution (green button)?
--SA
[no name] 12-Jun-11 18:51pm    
yes of course to have some points more, oh my god...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900