Untitled
unknown
plain_text
3 years ago
1.0 kB
15
Indexable
using System;
using System.Security.Cryptography;
using System.Text;
namespace Hasz
{
class Program
{
static void Main(string[] args)
{
string stringKtoryHashuje = "Ala ma kota";
Console.WriteLine(HashString(stringKtoryHashuje));
Console.ReadKey();
}
static string HashString(string textToHash)
{
byte[] data = Encoding.UTF8.GetBytes(textToHash);
byte[] hash;
SHA512 shaM = new SHA512Managed();
hash = shaM.ComputeHash(data);
string wynik = ByteArrayToString(hash);
return wynik;
}
static string ByteArrayToString(byte[] b)
{
StringBuilder hex = new StringBuilder(b.Length * 2);
foreach (byte element in b)
{
hex.AppendFormat("{0:x2}", element);
}
return hex.ToString();
}
}
}
Editor is loading...