SQL bigint hash to match c# int64 hash [duplicate]

依然范特西╮ 提交于 2019-12-01 16:55:19

Your SQL bigint takes the last 8 bytes while the c# implementation takes the first 8 bytes (and reverses them because its running on little endian).

Take the proper Range of the array in C# and reverse it. Then you should be fine.

Did some coding:

System.Security.Cryptography.SHA1 c = System.Security.Cryptography.SHA1.Create();
byte[] b = c.ComputeHash(Encoding.UTF8.GetBytes("google.com"));
long value = BitConverter.ToInt64(b, 12);
value = IPAddress.HostToNetworkOrder(value);

Debug.WriteLine(value);
// writes 2172193747348806725
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!