Comments (4)
Test values used: txt file named hash.txt with contents:
test
xxHash value received: 398167db5dcadc4f
xxhash value expected: 4fdcca5ddb678139
note that if I use my helper to reverse the bytes, it then provides the correct output (the output hash strings just have the bytes in reverse order the first one ends with 4f, and the second one starts with 4f, etc.)
from data.hashfunction.
I just noticed a similar thing with the jenkins one at a time. When I use https://www.pelock.com/products/hash-calculator the value for the hash of "a" is CA2E9442. When I use System.Data.HashFunction, I get 42942eca.
If I use this method I get the same results as pelock.com:
uint jenkins_one_at_a_time_hash(string key, int? length = null)
{
uint hash, i;
for (hash = i = 0; i < key.Length; ++i)
{
hash += key[(int)i];
hash += (hash << 10);
hash ^= (hash >> 6);
}
hash += (hash << 3);
hash ^= (hash >> 11);
hash += (hash << 15);
return hash;
}
from data.hashfunction.
Any update on this? We have encountered this same problem as well. As long as you keep using this method the wrong way and compare hashes with this incorrect result, you'll be fine.
But we have to mix our .NET functionality and the hashes generated by this package with the AsHexString
method with PHP functionality now which will also generate xxHash hex string values, and noticed that they did not match. The PHP library gives the correct result, this one does not.
I believe it can be traced back to the usage of BitConverter.GetBytes
though, which (depending on your machine'es endianness) may reverse bytes around.
from data.hashfunction.
This is expected behavior due to the ambiguity of what it means to convert a given hash value to a hex string. For hash values that output 8, 16, 32, or 64 bits, they usually are output as a native byte, ushort, uint, or ulong.
When converting a native integer value to a hex value, the value is generally output as a big-endian string; however, when the result is truly a byte array (regardless of size) and we convert to a hex string, the value is output in byte-order (which technically is little-endian).
The exact behavior among different hash functions when executed on a big endian machine versus little endian isn't necessarily defined; however, a vast majority of them will return the same logical native value when they return a native value, and will return the same byte array if they return a byte array.
All of that aside, I unfortunately am no longer able to maintain this library due to personal responsibilities and will be archiving it soon. I'm happy to transfer ownership to a new maintainer if someone else is interested in taking ownership of this library.
from data.hashfunction.
Related Issues (20)
- Support for stream block processing HOT 5
- Performance HOT 2
- AsHexstring() function in CityHash gives reverse output HOT 4
- CRC Hash Error HOT 1
- Example in README is wrong signature HOT 1
- add t1ha (Fast Positive Hash) HOT 1
- Valid hash size for xxHash HOT 1
- Re-namespace and rename packages HOT 2
- Move LICENSE file include to Directory.Build.props
- Better separate hash functions that aren't variable size into distinct types.
- Review and normalize XML comments and function parameters
- Ensure cross-implementation consistency in variable names
- Re-order using statements
- Ensure 100% test coverage
- Support Span<byte> as Hash-function input
- announcement: PowerShell Module with this Hash functions
- Different strings, but the xxHash calculation result is the same HOT 1
- Result of CityHash64 doesn't match the reference implementation on strings of 64*n (n > 1) lengths
- Outdated CityHash NuGet package with too slow 128-bit implementation HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from data.hashfunction.