Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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()
- {
- string input="d8818b38a14e7461e87301ad4b9809b558bcbca816b650cd470452e018ada255";
- string output="740f81cd7deed90102a36e41a74cbe7373856ff647c66d0c945db8c4dfc67130";
- Console.WriteLine("Expected:");
- Console.WriteLine(output);
- var serverSeed = StringToByteArray(input);
- using (var sha = SHA256.Create())
- {
- var hash = sha.ComputeHash(serverSeed);
- string ou=BitConverter.ToString(SHA256.Create().ComputeHash(Encoding.ASCII.GetBytes(input))).Replace("-", "").ToLower();
- Console.WriteLine("\nActual:");
- Console.WriteLine(ou);
- if(output==ou){
- Console.WriteLine("\nThey are the same");
- }else Console.WriteLine("\nThey aren't the same");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement