Upload files

Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com>
This commit is contained in:
2025-06-02 19:18:51 +07:00
parent 57a8516aea
commit 5403d2125f
12 changed files with 507 additions and 0 deletions

5
.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
.vs
bin/
obj/
packages/
*.csproj.user

6
xaskel_coder/App.config Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
</configuration>

87
xaskel_coder/Program.cs Normal file
View File

@@ -0,0 +1,87 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
namespace xaskel_coder
{
internal class Program
{
private const int encodeSize = 3000; // byte count to encode
private static readonly List<string> extensions = new List<string> { ".col", ".txd", ".dff" };
static void Main()
{
Console.Write("Enter password: ");
string password = Console.ReadLine().Trim();
if (string.IsNullOrWhiteSpace(password))
return;
Console.Write("Getting files list... ");
List<string> files = GetFiles(Console.ReadLine().Trim());
if (files.Count == 0)
return;
Console.WriteLine("Done.");
Console.Write("Encoding files... ");
foreach (string file in files)
{
EncryptFile(file, password);
}
Console.WriteLine("Done.");
Console.ReadLine();
}
static List<string> GetFiles(string directoryPath)
{
List<string> files = Directory.GetFiles(directoryPath, "*.*", SearchOption.TopDirectoryOnly)
.Where(file => extensions.Contains(Path.GetExtension(file).ToLower()))
.ToList();
return files;
}
static void EncryptFile(string filePath, string password)
{
string newFilePath = filePath + "rw";
using (var md5 = MD5.Create())
{
byte[] inputBytes = Encoding.UTF8.GetBytes(password),
hashBytes = md5.ComputeHash(inputBytes);
string key = BitConverter.ToString(hashBytes).Replace("-", "").Substring(0, 16);
byte[] data = File.ReadAllBytes(filePath);
int bytesToEncode = Math.Min(encodeSize, data.Length);
List<string> encoded = new List<string>();
for (int i = 0; i < bytesToEncode; i++)
{
encoded.Add(Tea.Encode(data[i].ToString(), key));
}
if (File.Exists(newFilePath))
{
File.Delete(newFilePath);
}
using (var fs = new FileStream(newFilePath, FileMode.CreateNew))
{
using (var writer = new BinaryWriter(fs))
{
string encodedString = string.Join("", encoded);
byte[] encodedBytes = Encoding.UTF8.GetBytes(encodedString);
writer.Write(encodedBytes);
if (data.Length > encodeSize)
{
writer.Write(data, encodeSize, data.Length - encodeSize);
}
}
}
}
}
}
}

View File

@@ -0,0 +1,33 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Общие сведения об этой сборке предоставляются следующим набором
// набора атрибутов. Измените значения этих атрибутов для изменения сведений,
// связанные с этой сборкой.
[assembly: AssemblyTitle("xaskel_coder")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("xaskel_coder")]
[assembly: AssemblyCopyright("Lev Rusanov © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми
// для компонентов COM. Если необходимо обратиться к типу в этой сборке через
// из модели COM задайте для атрибута ComVisible этого типа значение true.
[assembly: ComVisible(false)]
// Следующий GUID представляет идентификатор typelib, если этот проект доступен из модели COM
[assembly: Guid("11ff5d14-ba40-434b-8b87-8031df3b1479")]
// Сведения о версии сборки состоят из указанных ниже четырех значений:
//
// Основной номер версии
// Дополнительный номер версии
// Номер сборки
// Номер редакции
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

54
xaskel_coder/Tea.cs Normal file
View File

@@ -0,0 +1,54 @@
using System;
using System.Text;
namespace xaskel_coder
{
public static class Tea
{
private const uint DELTA = 0x9E3779B9;
public static string Encode(string text, string key)
{
if (string.IsNullOrEmpty(text))
return string.Empty;
byte[] textBytes = Encoding.UTF8.GetBytes(text),
keyBytes = Encoding.UTF8.GetBytes(key);
uint[] key32 = new uint[4];
Buffer.BlockCopy(keyBytes, 0, key32, 0, Math.Min(keyBytes.Length, 16));
int textLength = textBytes.Length,
bufferLength = textLength;
if (bufferLength % 4 != 0)
bufferLength += 4 - (bufferLength % 4);
bufferLength = bufferLength / 4;
uint[] text32 = new uint[bufferLength + 1];
Buffer.BlockCopy(textBytes, 0, text32, 0, textBytes.Length);
uint previous = 0;
for (int offset = 0; offset < bufferLength; offset++)
{
uint v = text32[offset],
sum = 0;
for (int i = 0; i < 32; i++)
{
v += (((previous << 4) ^ (previous >> 5)) + previous) ^ (sum + key32[sum & 3]);
sum += DELTA;
previous += (((v << 4) ^ (v >> 5)) + v) ^ (sum + key32[(sum >> 11) & 3]);
}
text32[offset] = v;
}
text32[bufferLength] = previous;
byte[] resultBytes = new byte[(bufferLength + 1) * 4];
Buffer.BlockCopy(text32, 0, resultBytes, 0, resultBytes.Length);
return Convert.ToBase64String(resultBytes);
}
}
}

View File

@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{11FF5D14-BA40-434B-8B87-8031DF3B1479}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>xaskel_coder</RootNamespace>
<AssemblyName>xaskel_coder</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Tea.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
</configuration>

88
xaskel_decoder/Program.cs Normal file
View File

@@ -0,0 +1,88 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
namespace xaskel_decoder
{
internal class Program
{
private const int blockSize = 12; // encoded block length
private const int encodeSize = 3000; // encoded byte count
private const int decodeSize = blockSize * encodeSize;
private static readonly string[] extensions = { ".colrw", ".colc", ".txdrw", ".txdc", ".dffrw", ".dffc" };
static void Main()
{
Console.Write("Enter password: ");
string password = Console.ReadLine().Trim();
if (string.IsNullOrWhiteSpace(password))
return;
Console.Write("Getting files list... ");
List<string> files = GetFiles(Console.ReadLine().Trim());
if (files.Count == 0)
return;
Console.WriteLine("Done.");
Console.Write("Encoding files... ");
foreach (string file in files)
{
DecryptFile(file, password);
}
Console.WriteLine("Done.");
Console.ReadLine();
}
static List<string> GetFiles(string directoryPath)
{
List<string> files = Directory.GetFiles(directoryPath, "*.*", SearchOption.TopDirectoryOnly)
.Where(file => extensions.Contains(Path.GetExtension(file).ToLower()))
.ToList();
return files;
}
static void DecryptFile(string filePath, string password)
{
string newFilePath = filePath + ".decoded";
using (var md5 = MD5.Create())
{
byte[] inputBytes = Encoding.UTF8.GetBytes(password);
byte[] hashBytes = md5.ComputeHash(inputBytes);
string key = BitConverter.ToString(hashBytes).Replace("-", "").Substring(0, 16);
byte[] data = File.ReadAllBytes(filePath);
string fileContent = Encoding.UTF8.GetString(data);
int bytesToDecode = Math.Min(decodeSize, fileContent.Length);
List<byte> decodedBytes = new List<byte>();
for (int i = 0; i < bytesToDecode; i += blockSize)
{
int length = Math.Min(blockSize, bytesToDecode - i);
string block = fileContent.Substring(i, length);
string decrypted = Tea.Decode(block, key);
decodedBytes.AddRange(Encoding.UTF8.GetBytes(decrypted));
}
if (File.Exists(newFilePath))
{
File.Delete(newFilePath);
}
using (var fs = new FileStream(newFilePath, FileMode.CreateNew))
{
fs.Write(decodedBytes.ToArray(), 0, decodedBytes.Count);
if (data.Length > decodeSize)
{
fs.Write(data, decodeSize, data.Length - decodeSize);
}
}
}
}
}
}

View File

@@ -0,0 +1,33 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Общие сведения об этой сборке предоставляются следующим набором
// набора атрибутов. Измените значения этих атрибутов для изменения сведений,
// связанные с этой сборкой.
[assembly: AssemblyTitle("xaskel_decoder")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("xaskel_decoder")]
[assembly: AssemblyCopyright("Lev Rusanov © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми
// для компонентов COM. Если необходимо обратиться к типу в этой сборке через
// из модели COM задайте для атрибута ComVisible этого типа значение true.
[assembly: ComVisible(false)]
// Следующий GUID представляет идентификатор typelib, если этот проект доступен из модели COM
[assembly: Guid("67779f52-b434-4645-a134-977977cfa8f3")]
// Сведения о версии сборки состоят из указанных ниже четырех значений:
//
// Основной номер версии
// Дополнительный номер версии
// Номер сборки
// Номер редакции
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

56
xaskel_decoder/Tea.cs Normal file
View File

@@ -0,0 +1,56 @@
using System;
using System.Text;
namespace xaskel_decoder
{
public static class Tea
{
private const uint DELTA = 0x9E3779B9;
public static string Decode(string data, string key)
{
if (string.IsNullOrEmpty(data))
return string.Empty;
byte[] dataBytes = Convert.FromBase64String(data),
keyBytes = Encoding.UTF8.GetBytes(key);
uint[] key32 = new uint[4];
Buffer.BlockCopy(keyBytes, 0, key32, 0, Math.Min(keyBytes.Length, 16));
int dataLength = dataBytes.Length,
dataBlocks = dataLength / 4,
numPasses = dataBlocks - 1;
if (numPasses <= 0)
return string.Empty;
uint[] data32 = new uint[dataBlocks];
Buffer.BlockCopy(dataBytes, 0, data32, 0, dataBytes.Length);
uint previous = data32[numPasses];
for (int offset = numPasses - 1; offset >= 0; offset--)
{
uint v = data32[offset],
sum = 0xC6EF3720;
for (int i = 0; i < 32; i++)
{
previous -= (((v << 4) ^ (v >> 5)) + v) ^ (sum + key32[(sum >> 11) & 3]);
sum -= DELTA;
v -= (((previous << 4) ^ (previous >> 5)) + previous) ^ (sum + key32[sum & 3]);
}
data32[offset] = v;
}
int byteLength = dataBytes.Length - 5;
for (; byteLength >= 0 && dataBytes[byteLength] == 0; byteLength--) ;
byte[] resultBytes = new byte[byteLength + 1];
Buffer.BlockCopy(data32, 0, resultBytes, 0, resultBytes.Length);
return Encoding.UTF8.GetString(resultBytes);
}
}
}

View File

@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{67779F52-B434-4645-A134-977977CFA8F3}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>xaskel_decoder</RootNamespace>
<AssemblyName>xaskel_decoder</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Tea.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

31
xaskel_soft.sln Normal file
View File

@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.13.35931.197 d17.13
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "xaskel_coder", "xaskel_coder\xaskel_coder.csproj", "{11FF5D14-BA40-434B-8B87-8031DF3B1479}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "xaskel_decoder", "xaskel_decoder\xaskel_decoder.csproj", "{67779F52-B434-4645-A134-977977CFA8F3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{11FF5D14-BA40-434B-8B87-8031DF3B1479}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{11FF5D14-BA40-434B-8B87-8031DF3B1479}.Debug|Any CPU.Build.0 = Debug|Any CPU
{11FF5D14-BA40-434B-8B87-8031DF3B1479}.Release|Any CPU.ActiveCfg = Release|Any CPU
{11FF5D14-BA40-434B-8B87-8031DF3B1479}.Release|Any CPU.Build.0 = Release|Any CPU
{67779F52-B434-4645-A134-977977CFA8F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{67779F52-B434-4645-A134-977977CFA8F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{67779F52-B434-4645-A134-977977CFA8F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{67779F52-B434-4645-A134-977977CFA8F3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5FFC7CAE-9DC6-4A24-86D4-EC1F83B47448}
EndGlobalSection
EndGlobal