计算消息校验和 [英] Calculating Message Checksum

查看:74
本文介绍了计算消息校验和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个NDC Controller和Bank Host之间接口的应用程序(TCP/IP).我想知道如何计算控制器发送到银行主机的消息的校验和(消息字段中的字符总数).
校验和值的长度应为10,并且应为数值.
简而言之,我希望有一个校验和功能的源,如链接所示:
http://en.wikipedia.org/wiki/File:Checksum.svg

请帮忙.

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.

推荐答案

选择校验和算法并实现它.您有足够的算法可供选择,请参见 http://en.wikipedia.org/wiki/Checksum [ ^ ].请参阅本文引用的Web.

您可以使用已经实现的 Cryptographic Hash Function ( http://en.wikipedia.org/wiki/Cryptographic_hash_function [ ^ ]),位于名称空间System.Security.Cryptography中,例如,使用从System.Security.Cryptography.HashAlgorithm派生的分类之一,每个分类代表"SHA"家族的加密哈希函数(请参见 http ://en.wikipedia.org/wiki/SHA-2 [ ^ ])或MD5( http://en.wikipedia.org/wiki/MD5 [ ^ ]),使用类System.Security.Cryptography.MD5.

注意:请勿出于任何安全目的使用MD5,因为该算法被认为已损坏,请参见 http: //en.wikipedia.org/wiki/MD5 [ ^ ].对于校验和而言,这已经足够了.


在这里,我找到了CRC实现:
CRC编码 [
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.


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

—SA


这篇关于计算消息校验和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆