public static ComputeSha256Hash ( string fileName ) : string | ||
fileName | string | |
리턴 | string |
public static string ComputeSha256Hash(string fileName)
{
string sha256Hash = null;
try
{
using (FileStream stream = File.OpenRead(fileName))
{
using (var bufferedStream = new BufferedStream(stream, 1024 * 32))
{
var sha = new SHA256Cng();
byte[] checksum = sha.ComputeHash(bufferedStream);
sha256Hash = BitConverter.ToString(checksum).Replace("-", String.Empty);
}
}
}
catch (IOException) { }
catch (UnauthorizedAccessException) { }
return sha256Hash;
}