Created
April 16, 2020 07:03
-
-
Save ayende/e3871f2799c41a41deb9f082ac0771d8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static ushort GetShardId(string key) | |
{ | |
using var md5 = MD5.Create(); | |
{ | |
var hash = md5.ComputeHash(Encoding.UTF8.GetBytes(key)); | |
var integer = BigInteger.Abs(new BigInteger(hash)); | |
return (ushort)(integer % ushort.MaxValue); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment