Skip to content

Instantly share code, notes, and snippets.

@ayende
Created April 16, 2020 07:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ayende/e3871f2799c41a41deb9f082ac0771d8 to your computer and use it in GitHub Desktop.
Save ayende/e3871f2799c41a41deb9f082ac0771d8 to your computer and use it in GitHub Desktop.
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