How to calculate the md5 hash of a number in C#

1 Answer

0 votes
using System;
using System.Linq;
using System.Security.Cryptography;

class Program
{
    static void Main() {
        int number = 183494;
        String hash;
        
        using (var md5 = MD5.Create()) {
        	hash = String.Concat(md5.ComputeHash(BitConverter
        	                    .GetBytes(number))
        	                    .Select(x => x.ToString("x2")));
        }
        
        Console.Write(hash);
    }
}



/*
run:

953682c1ff0bbe837cb3912f47f09f80

*/

 



answered Jul 30, 2023 by avibootz

Related questions

1 answer 118 views
2 answers 221 views
2 answers 121 views
121 views asked Nov 20, 2023 by avibootz
1 answer 133 views
133 views asked Sep 25, 2023 by avibootz
1 answer 183 views
1 answer 153 views
1 answer 24 views
...