mirror of
https://github.com/JDM170/file_hash_checker
synced 2025-12-10 16:17:18 +07:00
Compare commits
4 Commits
5ebc893513
...
c_sharp
| Author | SHA1 | Date | |
|---|---|---|---|
|
61d57af6e5
|
|||
|
fe8c2af0ec
|
|||
|
21fc686d17
|
|||
|
522f2f827b
|
15
Program.cs
15
Program.cs
@@ -8,6 +8,8 @@ namespace file_hash_checker
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
private static readonly string regexHash = @"[a-zA-Z0-9]{32,}";
|
||||
|
||||
/*static int ReadBlock(Stream s, byte[] block)
|
||||
{
|
||||
int position = 0;
|
||||
@@ -85,7 +87,10 @@ namespace file_hash_checker
|
||||
Console.Write("> ");
|
||||
string data = Console.ReadLine().Trim();
|
||||
if (string.IsNullOrWhiteSpace(data))
|
||||
InputData(message);
|
||||
{
|
||||
Console.WriteLine("Файл не найден!");
|
||||
return InputData(message);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -97,13 +102,13 @@ namespace file_hash_checker
|
||||
|
||||
string hash = CalculateMD5(source);
|
||||
bool result = false;
|
||||
if (Regex.Match(toCompare, @"[a-zA-Z0-9]{32,}").Success)
|
||||
if (Regex.IsMatch(toCompare, regexHash))
|
||||
result = hash == toCompare.ToLower();
|
||||
else if (File.Exists(toCompare))
|
||||
if (toCompare.EndsWith(".md5"))
|
||||
if (toCompare.EndsWith(".txt") || toCompare.EndsWith(".md5"))
|
||||
{
|
||||
var fileData = File.ReadAllText(toCompare);
|
||||
Match match = Regex.Match(fileData, @"[a-zA-Z0-9]{32,}");
|
||||
string fileData = File.ReadAllText(toCompare);
|
||||
Match match = Regex.Match(fileData, regexHash);
|
||||
if (match.Success)
|
||||
result = hash == match.Value;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user