Generate a unique value for a combination of two numbers

后端 未结 9 924
有刺的猬
有刺的猬 2020-12-16 16:09

Consider I\'ve two numbers 1023232 & 44. I want to generate a unique number representing this combination of numbers. How can i generate it?

Requirement

9条回答
  •  甜味超标
    2020-12-16 17:02

    If you can represent it as a string, this should work:

    Hash((int1 | int2).ToString());
    

    Like so:

    public static string Hash(string plaintext)
    {
    var hashAlgorithm = new SHA1CryptoServiceProvider();
    var unhashedBuffer = Encoding.Default.GetBytes(plaintext);
    var hashedBuffer = hashAlgorithm.ComputeHash(unhashedBuffer);
    return Convert.ToBase64String(hashedBuffer);
    )
    

提交回复
热议问题