Jump to content
leftler

Can't get server seed to match server seed hash.

Recommended Posts

I was going through a manual verification process myself using no outside resources like dicesites.com. After changing my server key I had the following info

Capture.thumb.PNG.37f2de87ea2a1bb9ceb4f6e8df54fa96.PNG

 

I then wrote a small C# program to hash the server seed and see what I got

 

using System;
using System.Text;
using System.Security.Cryptography;

					
public class Program
{
	public static byte[] StringToByteArray(String hex)
	{
		int NumberChars = hex.Length;
		byte[] bytes = new byte[NumberChars / 2];
		for (int i = 0; i < NumberChars; i += 2)
			bytes[i / 2] = Convert.ToByte(hex.Substring(i, 2), 16);
		return bytes;
	}
	public static string ByteArrayToString(byte[] ba)
	{
		StringBuilder hex = new StringBuilder(ba.Length * 2);
		foreach (byte b in ba)
			hex.AppendFormat("{0:x2}", b);
		return hex.ToString();
	}
	
	public static void Main()
	{
		Console.WriteLine("Expected:");
		Console.WriteLine("740f81cd7deed90102a36e41a74cbe7373856ff647c66d0c945db8c4dfc67130");
		
		var serverSeed = StringToByteArray("d8818b38a14e7461e87301ad4b9809b558bcbca816b650cd470452e018ada255");
		using (var sha = SHA256.Create())
		{
			var hash = sha.ComputeHash(serverSeed);
			Console.WriteLine("Actual:");
			Console.WriteLine(ByteArrayToString(hash));
		}
	}
}

Here is a runable version https://dotnetfiddle.net/qyx6wo

When I run it I get a output of

Quote

Expected:
740f81cd7deed90102a36e41a74cbe7373856ff647c66d0c945db8c4dfc67130
Actual:
52a25b439e0d6e0b1b39d2e2243bd950815167714fac77e22c64f5f5a3653028

What am I doing wrong in the process of hashing the server seed that it is causing the resultant hash to not match?

Share this post


Link to post
Share on other sites

Yes, the problem was the missing Encoding.ASCII.GetBytes(input), because the server seed was displayed as a hex value I thought it was giving me the actual binary value that was being passed in as the key, the real value being passed in as the server key is 

Quote

64383831386233386131346537343631653837333031616434623938303962353538626362636138313662363530636434373034353265303138616461323535

and that 512 bit value is what is hashed.

Share this post


Link to post
Share on other sites

×