Güncel C# Dosya Hash Hesaplama (MD5, SHA256)

Falcon

Yönetici
Kod:
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;

class Program
{
    static void Main()
    {
        string file = @"C:\Windows\notepad.exe";

        using (var md5 = MD5.Create())
        using (var stream = File.OpenRead(file))
        {
            string hash = BitConverter.ToString(md5.ComputeHash(stream)).Replace("-", "");
            Console.WriteLine("MD5: " + hash);
        }

        using (var sha = SHA256.Create())
        using (var stream = File.OpenRead(file))
        {
            string hash = BitConverter.ToString(sha.ComputeHash(stream)).Replace("-", "");
            Console.WriteLine("SHA256: " + hash);
        }
    }
}
 
Geri
Üst