Upload files

Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com>
This commit is contained in:
2025-06-02 23:59:28 +07:00
parent 5403d2125f
commit a24da7a4fd
2 changed files with 15 additions and 23 deletions

View File

@@ -19,7 +19,7 @@ namespace xaskel_coder
if (string.IsNullOrWhiteSpace(password))
return;
Console.Write("Getting files list... ");
Console.Write("Enter directory path: ");
List<string> files = GetFiles(Console.ReadLine().Trim());
if (files.Count == 0)
return;
@@ -47,7 +47,7 @@ namespace xaskel_coder
{
string newFilePath = filePath + "rw";
using (var md5 = MD5.Create())
using (MD5 md5 = MD5.Create())
{
byte[] inputBytes = Encoding.UTF8.GetBytes(password),
hashBytes = md5.ComputeHash(inputBytes);
@@ -67,18 +67,14 @@ namespace xaskel_coder
File.Delete(newFilePath);
}
using (var fs = new FileStream(newFilePath, FileMode.CreateNew))
using (FileStream fs = new FileStream(newFilePath, FileMode.CreateNew))
{
using (var writer = new BinaryWriter(fs))
using (BinaryWriter 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);
}
writer.Write(data, encodeSize, data.Length - encodeSize);
}
}
}

View File

@@ -21,7 +21,7 @@ namespace xaskel_decoder
if (string.IsNullOrWhiteSpace(password))
return;
Console.Write("Getting files list... ");
Console.Write("Enter directory path: ");
List<string> files = GetFiles(Console.ReadLine().Trim());
if (files.Count == 0)
return;
@@ -49,10 +49,10 @@ namespace xaskel_decoder
{
string newFilePath = filePath + ".decoded";
using (var md5 = MD5.Create())
using (MD5 md5 = MD5.Create())
{
byte[] inputBytes = Encoding.UTF8.GetBytes(password);
byte[] hashBytes = md5.ComputeHash(inputBytes);
byte[] inputBytes = Encoding.UTF8.GetBytes(password),
hashBytes = md5.ComputeHash(inputBytes);
string key = BitConverter.ToString(hashBytes).Replace("-", "").Substring(0, 16);
byte[] data = File.ReadAllBytes(filePath);
@@ -63,8 +63,8 @@ namespace xaskel_decoder
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);
string block = fileContent.Substring(i, length),
decrypted = Tea.Decode(block, key);
decodedBytes.AddRange(Encoding.UTF8.GetBytes(decrypted));
}
@@ -72,17 +72,13 @@ namespace xaskel_decoder
{
File.Delete(newFilePath);
}
using (var fs = new FileStream(newFilePath, FileMode.CreateNew))
using (FileStream fs = new FileStream(newFilePath, FileMode.CreateNew))
{
fs.Write(decodedBytes.ToArray(), 0, decodedBytes.Count);
if (data.Length > decodeSize)
{
fs.Write(data, decodeSize, data.Length - decodeSize);
}
fs.Write(data, decodeSize, data.Length - decodeSize);
}
}
}
}
}
}