哈希码和校验和 - 有什么区别? [英] Hash Code and Checksum - what's the difference?

查看:768
本文介绍了哈希码和校验和 - 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的理解是哈希码和校验和是相似的东西 - 一个数值,是为一块数据计算的,它是相对唯一的。



即产生相同数字哈希/校验和值的两个数据块的概率足够低,以至于应用程序可以忽略它。



那么我们有两个或者在哈希码和校验和之间有重要的区别? 我会说a 校验和 必然 a hashcode 。但是,并不是所有的hashcode都会产生很好的校验和。

校验和有一个特殊的用途 - 校验或检查数据的完整性(某些可以通过允许错误更正来超越这一点)。 良好的校验和很容易计算,并且可以检测到许多类型的数据损坏(例如一个,两个,三个错误位)。

哈希码简单地描述了一个数学函数将数据映射到某个值。当用作数据结构索引的方法(例如散列表)时,低碰撞概率是可取的。

My understanding is that a hash code and checksum are similar things - a numeric value, computed for a block of data, that is relatively unique.

i.e. The probability of two blocks of data yielding the same numeric hash/checksum value is low enough that it can be ignored for the purposes of the application.

So do we have two words for the same thing, or are there important differences between hash codes and checksums?

解决方案

I would say that a checksum is necessarily a hashcode. However, not all hashcodes make good checksums.

A checksum has a special purpose --- it verifies or checks the integrity of data (some can go beyond that by allowing for error-correction). "Good" checksums are easy to compute, and can detect many types of data corruptions (e.g. one, two, three erroneous bits).

A hashcode simply describes a mathematical function that maps data to some value. When used as a means of indexing in data structures (e.g. a hash table), a low collision probability is desirable.

这篇关于哈希码和校验和 - 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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