Ⅰ. はじめに
タイトルの通り「C#でxxHashを計算する方法」です。
Ⅱ. やり方
1. 必要なパッケージをインストールする
dotnet add package System.Data.HashFunction.xxHash --version 2.0.0
2. プログラムを書く
using System.Data.HashFunction.xxHash; using System.Text; var xxHashConfig = new xxHashConfig() { Seed = 123456789, HashSizeInBits = 64 }; var xxHash = xxHashFactory.Instance.Create(xxHashConfig); var bytes = Encoding.UTF8.GetBytes("hoge"); var hash = xxHash.ComputeHash(bytes); Console.WriteLine(BitConverter.ToUInt64(hash.Hash));
実行結果
13288037748801071589