Skip to content
This repository was archived by the owner on May 13, 2022. It is now read-only.

xxHash gives incorrect value when using AsHexString method. #58

@AdamLeMmon01

Description

@AdamLeMmon01

I had to create a custom as hex string method to get the correct value.

Either the value is being stored under the hood with the bytes reversed, or just when using the AsHexString method the value is being reversed. Looking at the source, it's probably the storage format since AsHexString didn't appear to be reversing anything.

I had to generate my own helper method to get the hex string correctly. This was required for me as I'm trying to match up xxhashes from different languages and the c++ version I'm using (and several others I checked) did not have this issue.

//My own helper method I had to use to work around the ordering issue.
public static string AsHexString(byte[] hash, bool uppercase)
{
Array.Reverse(hash);//Note this reverse. This is currently required to work correctly
StringBuilder stringBuilder = new StringBuilder(hash.Length);
string format = uppercase ? "X2" : "x2";
foreach (byte num in hash)
stringBuilder.Append(num.ToString(format));
return stringBuilder.ToString();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions