Extract a common SHA1 helper.

This commit is contained in:
Paul Chote
2016-09-08 17:45:04 +01:00
parent 0d54f2994f
commit 9e8b18e7be
5 changed files with 43 additions and 19 deletions

View File

@@ -13,8 +13,8 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Threading.Tasks;
using OpenRA;
using OpenRA.FileFormats;
using OpenRA.Mods.Common.FileFormats;
using OpenRA.Widgets;
@@ -507,12 +507,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
return false;
using (var fileStream = File.OpenRead(filePath))
using (var csp = SHA1.Create())
{
var hash = new string(csp.ComputeHash(fileStream).SelectMany(a => a.ToString("x2")).ToArray());
if (hash != kv.Value)
if (CryptoUtil.SHA1Hash(fileStream) != kv.Value)
return false;
}
}
}
catch (Exception)