첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

▶ MD5 클래스 : ComputeHash 메소드를 사용해 MD5 해시값 구하기 예제

using System;

string md5HashValue = GetMD5HashValue("d:\\test.txt");

Console.WriteLine(md5HashValue);

 

300x250

 

▶ MD5 클래스 : ComputeHash 메소드를 사용해 MD5 해시값 구하기

using System;
using System.IO;
using System.Security.Cryptography;

#region MD5 해시값 구하기 - GetMD5HashValue(filePath)

/// <summary>
/// MD5 해시값 구하기
/// </summary>
/// <param name="filePath">파일 경로</param>
/// <returns>MD5 해시값</returns>
public string GetMD5HashValue(string filePath)
{
    using(MD5 md5 = MD5.Create())
    {
        using(FileStream stream = File.OpenRead(filePath))
        {
            return BitConverter.ToString(md5.ComputeHash(stream)).Replace("-", string.Empty);
        }
    }
}

#endregion
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요