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

namespace Com.Bocom.OpenApi
{
    namespace Security
    {
        namespace Digest
        {
            public class SHA256Digest
            {
                public static string Digest(string fileName)
                {
                    SHA256 hash = SHA256.Create();
                    FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
                    byte[] hashByte = hash.ComputeHash(stream);
 
                    stream.Close();
                    Console.WriteLine("上传文件hashh值：" + BitConverter.ToString(hashByte).Replace("-", "").ToLower());
                    return BitConverter.ToString(hashByte).Replace("-", "").ToLower();
                }
            }
        }
    }
}