-
-
Save minhhungit/65e9a903305c36bdbc21d8ac1c297b97 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