-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwormhash.cs
31 lines (27 loc) · 862 Bytes
/
wormhash.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System;
using System.Security.Cryptography;
using System.Text;
public class WormStoreHash
{
public static string ComputeHash(string data)
{
using (SHA256 sha256 = SHA256.Create())
{
// Convert the input data to a byte array and compute the hash
byte[] bytes = sha256.ComputeHash(Encoding.UTF8.GetBytes(data));
// Convert the byte array to a hex string
StringBuilder hashString = new StringBuilder();
for (int i = 0; i < bytes.Length; i++)
{
hashString.Append(bytes[i].ToString("x2"));
}
return hashString.ToString();
}
}
public static void Main()
{
string data = "Sample data to be hashed";
string hash = ComputeHash(data);
Console.WriteLine("Data Hash: " + hash);
}
}