hash

Git hash duplicates

不问归期 提交于 2020-12-09 16:53:58
问题 Git allows to retrieve the hash of the commit with commands like: git rev-parse HEAD which gives 33b316c or git rev-parse --short HEAD which gives 33b316cbeeab3d69e79b9fb659414af4e7829a32 I know that long hashes in practice will never collide. In practice, the short hashes are used much more often. I'd like to know what's the probability for the short ones to collide? Does git take any measures to overcome possible collisions (when for example using git checkout )? 回答1: I give a formula in my

Git hash duplicates

烈酒焚心 提交于 2020-12-09 16:52:58
问题 Git allows to retrieve the hash of the commit with commands like: git rev-parse HEAD which gives 33b316c or git rev-parse --short HEAD which gives 33b316cbeeab3d69e79b9fb659414af4e7829a32 I know that long hashes in practice will never collide. In practice, the short hashes are used much more often. I'd like to know what's the probability for the short ones to collide? Does git take any measures to overcome possible collisions (when for example using git checkout )? 回答1: I give a formula in my

Git hash duplicates

梦想的初衷 提交于 2020-12-09 16:52:28
问题 Git allows to retrieve the hash of the commit with commands like: git rev-parse HEAD which gives 33b316c or git rev-parse --short HEAD which gives 33b316cbeeab3d69e79b9fb659414af4e7829a32 I know that long hashes in practice will never collide. In practice, the short hashes are used much more often. I'd like to know what's the probability for the short ones to collide? Does git take any measures to overcome possible collisions (when for example using git checkout )? 回答1: I give a formula in my

Git hash duplicates

喜欢而已 提交于 2020-12-09 16:51:33
问题 Git allows to retrieve the hash of the commit with commands like: git rev-parse HEAD which gives 33b316c or git rev-parse --short HEAD which gives 33b316cbeeab3d69e79b9fb659414af4e7829a32 I know that long hashes in practice will never collide. In practice, the short hashes are used much more often. I'd like to know what's the probability for the short ones to collide? Does git take any measures to overcome possible collisions (when for example using git checkout )? 回答1: I give a formula in my

Redis 2.8.9源码

旧巷老猫 提交于 2020-12-06 18:25:24
Redis使用字典的方式实现了数据库键空间,今天就记录一下字典的实现方式。 Redis 对字典的描述和实现源码在 src/dict.h src/dict.c,关于学习Redis字典如何进行测试或debug,请参考另外一篇文章: Redis 2.8.9源码 - 字典哈希表操作函数头整理,并注释作用和参数说明(附测试方法和代码以及使用方法) 字典结构: typedef struct dict { dictType *type; //根据存储内容的不同,自定义一组回调函数来控制比较申请内存释放空间等操作 void *privdata; //用于回调函数使用 dictht ht[2]; //存放hash表的结构 0 默认使用0,rehash的时候使用1 int rehashidx; //默认为-1,rehash开始的时候该变量设置为0,完成后重新设置为-1 int iterators; //正在进行的安全迭代的数量,释放安全迭代后会减1 } dict; typedef struct dictType { unsigned int (*hashFunction)(const void *key); //针对不同类型进行hash计算的函数,返回hash值 void *(*keyDup)(void *privdata, const void *key); //复制key void *(

Right way to implement GetHashCode for this struct

陌路散爱 提交于 2020-12-01 09:17:55
问题 I want to use a date range (from one date to another date) as a key for a dictionary, so I wrote my own struct: struct DateRange { public DateTime Start; public DateTime End; public DateRange(DateTime start, DateTime end) { Start = start.Date; End = end.Date; } public override int GetHashCode() { // ??? } } What's the best way to implement GetHashCode so no two objects of a differing range will generate the same hash? I want hash collisions to be as unlikely as possible, though I understand

Right way to implement GetHashCode for this struct

馋奶兔 提交于 2020-12-01 09:15:31
问题 I want to use a date range (from one date to another date) as a key for a dictionary, so I wrote my own struct: struct DateRange { public DateTime Start; public DateTime End; public DateRange(DateTime start, DateTime end) { Start = start.Date; End = end.Date; } public override int GetHashCode() { // ??? } } What's the best way to implement GetHashCode so no two objects of a differing range will generate the same hash? I want hash collisions to be as unlikely as possible, though I understand

How to check if content of webpage has been changed?

假如想象 提交于 2020-11-26 06:48:09
问题 Basically I'm trying to run some code (Python 2.7) if the content on a website changes, otherwise wait for a bit and check it later. I'm thinking of comparing hashes , the problem with this is that if the page has changed a single byte or character, the hash would be different. So for example if the page display the current date on the page, every single time the hash would be different and tell me that the content has been updated. So... How would you do this? Would you look at the Kb size

Create SHA-256 hash from a Blob/File in javascript

半腔热情 提交于 2020-11-25 11:17:35
问题 I need to create a SHA-256 digest from a file (~6MB) inside the browser. The only way that I've managed to do it so far was like this: var reader = new FileReader(); reader.onload = function() { // this gets read of the mime-type data header var actual_contents = reader.result.slice(reader.result.indexOf(',') + 1); var what_i_need = new jsSHA(actual_contents, "B64").getHash("SHA-256", "HEX"); } reader.readAsDataURL(some_file); While this works correctly, the problem is that it's very slow. It

Create SHA-256 hash from a Blob/File in javascript

六月ゝ 毕业季﹏ 提交于 2020-11-25 11:06:49
问题 I need to create a SHA-256 digest from a file (~6MB) inside the browser. The only way that I've managed to do it so far was like this: var reader = new FileReader(); reader.onload = function() { // this gets read of the mime-type data header var actual_contents = reader.result.slice(reader.result.indexOf(',') + 1); var what_i_need = new jsSHA(actual_contents, "B64").getHash("SHA-256", "HEX"); } reader.readAsDataURL(some_file); While this works correctly, the problem is that it's very slow. It