Microsoft.CodeAnalysis.Sarif.HashUtilities.ComputeSha256Hash C# (CSharp) Method

ComputeSha256Hash() public static method

public static ComputeSha256Hash ( string fileName ) : string
fileName string
return 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))
                    {
                        using (var sha = new SHA256Cng())
                        {
                            byte[] checksum = sha.ComputeHash(bufferedStream);
                            sha256Hash = BitConverter.ToString(checksum).Replace("-", string.Empty);
                        }
                    }
                }
            }
            catch (IOException) { }
            catch (UnauthorizedAccessException) { }
            return sha256Hash;
        }