Create hash from last byte

CSharp · Console

/Program.cs

using System;
using System.Collections.Generic;

public class Program
{
	public static void Main()
	{
		var collection = new List<short>();
		for (int i = 300; i < 1000; i++)
		{
			var md5Hash = CreateMD5(i);
			collection.Add(md5Hash);			
		}
		collection.Sort();
		collection.ForEach(r => Console.WriteLine(r));
		
	}

	public static short CreateMD5(int input)
	{
		// Use input to calculate MD5 hash
		using (System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create())
		{
			
			byte[] inputBytes = BitConverter.GetBytes(input);
			byte[] hashBytes = md5.ComputeHash(inputBytes);
			// Console.WriteLine(BitConverter.ToString(hashBytes));
			
			// return the first byte from the 16 bytes
			return hashBytes[0];
		}
	}
}
;