From 5391bb8d79b5c0f5d13f7c8be64e0bc9719fbba8 Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Tue, 4 May 2021 11:10:06 +0200 Subject: [PATCH] File: clean up GetChecksum --- Modules.Filesystem/File.vb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Modules.Filesystem/File.vb b/Modules.Filesystem/File.vb index e29f65d4..82f78f02 100644 --- a/Modules.Filesystem/File.vb +++ b/Modules.Filesystem/File.vb @@ -73,10 +73,11 @@ Public Class File End Function Public Function GetChecksum(FilePath As String) As String - Using oStream As New BufferedStream(IO.File.OpenRead(FilePath), 1200000) - Dim oSHA As New SHA256Managed() - Dim oChecksum() As Byte = oSHA.ComputeHash(oStream) - Return BitConverter.ToString(oChecksum).Replace("-", String.Empty) + Using oFileStream = IO.File.OpenRead(FilePath) + Using oStream As New BufferedStream(oFileStream, 1200000) + Dim oChecksum() As Byte = SHA256.Create.ComputeHash(oStream) + Return BitConverter.ToString(oChecksum).Replace("-", String.Empty) + End Using End Using End Function