hash-function

Maximum length for MD5 input/output

若如初见. 提交于 2019-11-27 11:23:55
What is the maximum length of the string that can have md5 hashed? Or: If it has no limit, and if so what will be the max length of the md5 output value? MD5 processes an arbitrary-length message into a fixed-length output of 128 bits, typically represented as a sequence of 32 hexadecimal digits. The length of the message is unlimited . Append Length A 64-bit representation of b (the length of the message before the padding bits were added) is appended to the result of the previous step. In the unlikely event that b is greater than 2^64, then only the low-order 64 bits of b are used. The hash

Why does Git use a cryptographic hash function?

佐手、 提交于 2019-11-27 02:37:22
Why does Git use SHA-1 , a cryptographic hash function, instead of a faster non-cryptographic hash function? Related question: Stack Overflow question Why does Git use SHA-1 as version numbers? asks why Git uses SHA-1 as opposed to sequential numbers for commits. TLDR; from 2005 up to 2018/Git 2.18: SHA-1 (see below) 2019, will switch at some point to SHA-256 You can check that from Linus Torvalds himself, when he presented Git to Google back in 2007 : (emphasis mine) We check checksums that is considered cryptographically secure. Nobody has been able to break SHA-1, but the point is, SHA-1 as

Hash function for floats

穿精又带淫゛_ 提交于 2019-11-26 20:54:34
问题 I'm currently implementing a hash table in C++ and I'm trying to make a hash function for floats... I was going to treat floats as integers by padding the decimal numbers, but then I realized that I would probably reach the overflow with big numbers... Is there a good way to hash floats? You don't have to give me the function directly, but I'd like to see/understand different concepts... Notes: I don't need it to be really fast, just evenly distributed if possible. I've read that floats

unordered_map hash function c++

佐手、 提交于 2019-11-26 18:45:23
I need to define an unordered_map like this unordered_map<pair<int, int>, *Foo> , what is the syntax for defining and passing a hash and equal functions to this map? I've tried passing to it this object: class pairHash{ public: long operator()(const pair<int, int> &k) const{ return k.first * 100 + k.second; } }; and no luck: unordered_map<pair<int, int>, int> map = unordered_map<pair<int, int>, int>(1, *(new pairHash())); I have no Idea what is the size_type_Buskets means so I gave it 1 . What is the right way to do it? Thanks. This is an unfortunate omission in C++11; Boost has the answer in

Maximum length for MD5 input/output

做~自己de王妃 提交于 2019-11-26 15:33:38
问题 What is the maximum length of the string that can have md5 hashed? Or: If it has no limit, and if so what will be the max length of the md5 output value? 回答1: MD5 processes an arbitrary-length message into a fixed-length output of 128 bits, typically represented as a sequence of 32 hexadecimal digits. 回答2: The length of the message is unlimited. Append Length A 64-bit representation of b (the length of the message before the padding bits were added) is appended to the result of the previous

Why does Git use a cryptographic hash function?

微笑、不失礼 提交于 2019-11-26 10:08:55
问题 Why does Git use SHA-1, a cryptographic hash function, instead of a faster non-cryptographic hash function? Related question: Stack Overflow question Why does Git use SHA-1 as version numbers? asks why Git uses SHA-1 as opposed to sequential numbers for commits. 回答1: TLDR; from 2005 up to 2018/Git 2.18: SHA-1 (see below) 2019, will switch at some point to SHA-256 You can check that from Linus Torvalds himself, when he presented Git to Google back in 2007: (emphasis mine) We check checksums

unordered_map hash function c++

家住魔仙堡 提交于 2019-11-26 06:34:25
问题 I need to define an unordered_map like this unordered_map<pair<int, int>, *Foo> , what is the syntax for defining and passing a hash and equal functions to this map? I\'ve tried passing to it this object: class pairHash{ public: long operator()(const pair<int, int> &k) const{ return k.first * 100 + k.second; } }; and no luck: unordered_map<pair<int, int>, int> map = unordered_map<pair<int, int>, int>(1, *(new pairHash())); I have no Idea what is the size_type_Buskets means so I gave it 1 .

How does a Java HashMap handle different objects with the same hash code?

≡放荡痞女 提交于 2019-11-25 22:29:48
问题 As per my understanding I think: It is perfectly legal for two objects to have the same hashcode. If two objects are equal (using the equals() method) then they have the same hashcode. If two objects are not equal then they cannot have the same hashcode Am I correct? Now if am correct, I have the following question: The HashMap internally uses the hashcode of the object. So if two objects can have the same hashcode, then how can the HashMap track which key it uses? Can someone explain how the