Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
64f8ad0b42
|
|||
|
d5efc93429
|
|||
|
a24da7a4fd
|
@@ -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,13 @@ 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);
|
||||
byte[] encodedBytes = Encoding.UTF8.GetBytes(string.Join("", encoded));
|
||||
writer.Write(encodedBytes);
|
||||
|
||||
if (data.Length > encodeSize)
|
||||
{
|
||||
writer.Write(data, encodeSize, data.Length - encodeSize);
|
||||
}
|
||||
writer.Write(data, encodeSize, data.Length - encodeSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,13 +21,13 @@ 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;
|
||||
Console.WriteLine("Done.");
|
||||
|
||||
Console.Write("Encoding files... ");
|
||||
Console.Write("Decoding files... ");
|
||||
foreach (string file in files)
|
||||
{
|
||||
DecryptFile(file, password);
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -73,16 +73,12 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.13.35931.197 d17.13
|
||||
VisualStudioVersion = 17.13.35931.197
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "xaskel_coder", "xaskel_coder\xaskel_coder.csproj", "{11FF5D14-BA40-434B-8B87-8031DF3B1479}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "coder", "coder\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}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "decoder", "decoder\decoder.csproj", "{67779F52-B434-4645-A134-977977CFA8F3}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
||||
Reference in New Issue
Block a user