且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

计算消息校验和

更新时间:2023-02-06 15:43:24

选择校验和算法并实现它.您有足够的算法可供选择,请参见 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