some fixes
This commit is contained in:
parent
2f964b5b93
commit
544fbd19f4
|
@ -12,6 +12,21 @@
|
|||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
<PublishUrl>게시\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
|
@ -42,9 +57,6 @@
|
|||
<AssemblyOriginatorKeyFile>socialonthefile.snk</AssemblyOriginatorKeyFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="BencodeNET, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\BencodeNET.4.0.0\lib\netstandard2.0\BencodeNET.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Crc32.NET, Version=1.0.0.0, Culture=neutral, PublicKeyToken=dc0b95cf99bf4e99, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Crc32.NET.1.2.0\lib\net20\Crc32.NET.dll</HintPath>
|
||||
</Reference>
|
||||
|
@ -103,6 +115,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Config.cs" />
|
||||
<Compile Include="Helper\InfoHashExtractor.cs" />
|
||||
<Compile Include="Model\CfbfPartInfo.cs" />
|
||||
<Compile Include="Model\HashInfo.cs" />
|
||||
<Compile Include="Worker1.cs" />
|
||||
|
@ -192,16 +205,6 @@
|
|||
<ItemGroup>
|
||||
<None Include="Resources\document_paperclip_list_paper_icon_219544.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\..\OneDrive\문서\GitHub\androidxmldotnet\AndroidXml\AndroidXml.csproj">
|
||||
<Project>{607eeb2c-6b7c-409e-959e-3b458a109426}</Project>
|
||||
<Name>AndroidXml</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\..\OneDrive\문서\GitHub\SsdeepNET\Source\SsdeepNET\SsdeepNET.csproj">
|
||||
<Project>{b1244c5a-cdeb-4d1d-8807-bf40251abcab}</Project>
|
||||
<Name>SsdeepNET</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\2333410-android-os-smartphone_85588.png" />
|
||||
</ItemGroup>
|
||||
|
@ -214,5 +217,27 @@
|
|||
<ItemGroup>
|
||||
<None Include="Resources\tags_icon-icons.com_73382.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include=".NETFramework,Version=v4.8">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Microsoft .NET Framework 4.8%28x86 및 x64%29</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\androidxmldotnet\AndroidXml\AndroidXml.csproj">
|
||||
<Project>{e55ce5e9-aeec-4625-82ff-9c73dad2ba84}</Project>
|
||||
<Name>AndroidXml</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\SsdeepNET\Source\SsdeepNET\SsdeepNET.csproj">
|
||||
<Project>{1fc34ef4-5137-4069-a18a-d35afec5181f}</Project>
|
||||
<Name>SsdeepNET</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
|
@ -1,6 +1,4 @@
|
|||
using BencodeNET.Parsing;
|
||||
using BencodeNET.Torrents;
|
||||
using Force.Crc32;
|
||||
using Force.Crc32;
|
||||
using SsdeepNET;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
@ -20,26 +18,26 @@ namespace Catswords.DataType.Client.Helper
|
|||
|
||||
public string GetExtension()
|
||||
{
|
||||
string extension = string.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
if (Path.GetExtension(FilePath).Length > 0)
|
||||
{
|
||||
return Path.GetExtension(FilePath).Substring(1).ToUpper();
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
extension = Path.GetExtension(FilePath).Substring(1).ToLower();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
catch
|
||||
{
|
||||
return "";
|
||||
// nothing
|
||||
}
|
||||
|
||||
return extension;
|
||||
}
|
||||
|
||||
public string GetMD5()
|
||||
{
|
||||
string checksum = "";
|
||||
string checksum = string.Empty;
|
||||
|
||||
using (MD5 hasher = MD5.Create())
|
||||
{
|
||||
|
@ -55,7 +53,7 @@ namespace Catswords.DataType.Client.Helper
|
|||
|
||||
public string GetSHA1()
|
||||
{
|
||||
string checksum = "";
|
||||
string checksum = string.Empty;
|
||||
|
||||
using (SHA1 hasher = SHA1.Create())
|
||||
{
|
||||
|
@ -71,7 +69,7 @@ namespace Catswords.DataType.Client.Helper
|
|||
|
||||
public string GetCRC32()
|
||||
{
|
||||
string checksum = "";
|
||||
string checksum = string.Empty;
|
||||
|
||||
using (FileStream stream = File.OpenRead(FilePath))
|
||||
{
|
||||
|
@ -85,7 +83,7 @@ namespace Catswords.DataType.Client.Helper
|
|||
|
||||
public string GetSHA256()
|
||||
{
|
||||
string checksum = "";
|
||||
string checksum = string.Empty;
|
||||
|
||||
using (SHA256 hasher = SHA256.Create())
|
||||
{
|
||||
|
@ -134,14 +132,13 @@ namespace Catswords.DataType.Client.Helper
|
|||
|
||||
public string GetInfoHash()
|
||||
{
|
||||
string checksum = "";
|
||||
string checksum = string.Empty;
|
||||
string extension = GetExtension().ToLower();
|
||||
|
||||
if (extension == "torrent")
|
||||
{
|
||||
BencodeParser parser = new BencodeParser();
|
||||
Torrent torrent = parser.Parse<Torrent>(FilePath);
|
||||
checksum = BitConverter.ToString(torrent.GetInfoHashBytes()).Replace("-", "").ToLowerInvariant();
|
||||
var extractor = new InfoHashExtractor(FilePath);
|
||||
checksum = extractor.GetString();
|
||||
}
|
||||
|
||||
return checksum;
|
||||
|
@ -149,7 +146,7 @@ namespace Catswords.DataType.Client.Helper
|
|||
|
||||
public string GetSSDEEP()
|
||||
{
|
||||
string checksum = "";
|
||||
string checksum = string.Empty;
|
||||
|
||||
using (FileStream stream = File.OpenRead(FilePath))
|
||||
{
|
||||
|
@ -165,7 +162,7 @@ namespace Catswords.DataType.Client.Helper
|
|||
|
||||
public string GetHexView(byte[] Data)
|
||||
{
|
||||
string output = "";
|
||||
string output = string.Empty;
|
||||
|
||||
StringBuilder strb = new StringBuilder();
|
||||
StringBuilder text = new StringBuilder();
|
||||
|
|
51
Catswords.DataType.Client/Helper/InfoHashExtractor.cs
Normal file
51
Catswords.DataType.Client/Helper/InfoHashExtractor.cs
Normal file
|
@ -0,0 +1,51 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Catswords.DataType.Client.Helper
|
||||
{
|
||||
public class InfoHashExtractor
|
||||
{
|
||||
private string FilePath;
|
||||
|
||||
public InfoHashExtractor(string filePath)
|
||||
{
|
||||
FilePath = filePath;
|
||||
}
|
||||
|
||||
public string GetString()
|
||||
{
|
||||
string infoHashString = "";
|
||||
|
||||
try
|
||||
{
|
||||
// 토렌트 파일을 바이트 배열로 읽어옴
|
||||
byte[] torrentData = File.ReadAllBytes(FilePath);
|
||||
|
||||
// 토렌트 파일에서 InfoHash 추출
|
||||
byte[] infoHash = ExtractInfoHash(torrentData);
|
||||
|
||||
// InfoHash를 문자열로 변환하여 출력
|
||||
infoHashString = BitConverter.ToString(infoHash).Replace("-", "").ToLower();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("An error occurred: " + ex.Message);
|
||||
}
|
||||
|
||||
return infoHashString;
|
||||
}
|
||||
|
||||
private byte[] ExtractInfoHash(byte[] torrentData)
|
||||
{
|
||||
// 토렌트 파일의 구조에 따라 InfoHash 위치 파악
|
||||
int start = Array.IndexOf(torrentData, (byte)'4', 0);
|
||||
int end = Array.IndexOf(torrentData, (byte)'e', start);
|
||||
|
||||
// InfoHash 추출
|
||||
byte[] infoHash = new byte[20];
|
||||
Array.Copy(torrentData, start + 1, infoHash, 0, 20);
|
||||
|
||||
return infoHash;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="BencodeNET" version="4.0.0" targetFramework="net48" />
|
||||
<package id="Crc32.NET" version="1.2.0" targetFramework="net48" />
|
||||
<package id="MetadataExtractor" version="2.8.1" targetFramework="net48" />
|
||||
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net48" />
|
||||
|
|
Loading…
Reference in New Issue
Block a user