반응형
[C#] Get HashString, from File Strem
파일스트림의 고유한 해쉬값 추출하는 내용
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string fileName = @"c:\1.tif";
MessageBox.Show(GetChecksum(fileName));
}
public static string GetChecksum(string sPathFile)
{
if (!File.Exists(sPathFile))
return null;
using (FileStream stream = File.OpenRead(sPathFile))
{
MD5 md5 = new MD5CryptoServiceProvider();
byte[] byteChecksum = md5.ComputeHash(stream);
return BitConverter.ToString(byteChecksum).Replace("-", String.Empty);
}
}
}
}
반응형
'I.T > Programming' 카테고리의 다른 글
| [C#] Ldap Server User 인증하기 (0) | 2016.11.10 |
|---|---|
| [C#] 리스트뷰 칼럼에 텍스트 박스 넣기, Listview, textbox (2) | 2016.11.10 |
| [Custom URI] Custom URI 적용(경고창제어), NSIS Custom URI 적용하기 (Windows & Explorer 예제, C#, NSIS Script) (0) | 2016.07.15 |
| Windbg 윈디버그 실행하여 crash dump 확인하기(pdb symbol) Visual Studio 2010 (0) | 2015.10.27 |
| 비쥬얼스튜디오(Visual Studio) 릴리즈모드(Release Mode)에서 디버깅 (0) | 2015.09.03 |
