Help us understand the problem. What is going on with this article?

MD5のハッシュ値を計算する

More than 5 years have passed since last update.

MD5のハッシュを計算するには、次の名前空間を使用します。

using System.Security.Cryptography;

計算はMD5.ComputeHash( )で行います。オーバーロードは主にbyte[ ]またはStreamです。

static string Run( string path )
{
    var md5 = MD5.Create( );
    using ( var stream = File.OpenRead( path ) )
    {
        return string.Concat(
            md5.ComputeHash( stream )
            .Select( x => string.Format( "{0:x2}", x ) )
        );
    }
}

このサンプルコードの返却値は下記のような感じになります。
2c99a6cd27f781f6862f98e1841b829c

kuchikios
✌('ω')✌
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away