Написана система взаимодействия со строками
Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com>
This commit is contained in:
27
Utils.cs
Normal file
27
Utils.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace SaveWizard_rewritten
|
||||
{
|
||||
static class Utils
|
||||
{
|
||||
public static string GenerateMD5(string filename)
|
||||
{
|
||||
if (!File.Exists(filename))
|
||||
return null;
|
||||
using (var md5 = MD5.Create())
|
||||
{
|
||||
using (FileStream stream = File.OpenRead(filename))
|
||||
md5.ComputeHash(stream);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
byte[] hash = md5.Hash;
|
||||
for (int i = 0; i < hash.Length; i++)
|
||||
sb.Append(hash[i].ToString("x2"));
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user