English please

alphons <alphons@heijden.com> 5 Aug 2025, 09:57
62f81634826680fd3679b4d6591e05dff5090c96
2 files changed
  • DecryptPayload/Program.cs
  • EncryptedPayload/Program.cs
diff --git a/DecryptPayload/Program.cs b/DecryptPayload/Program.cs
index 472e5fa..7852dc2 100644
--- a/DecryptPayload/Program.cs
+++ b/DecryptPayload/Program.cs
@@ -7,7 +7,7 @@ class Program(string passwordPrompt, string embeddedResourceName)
{
static void Main(string[] args)
{
- Program program = new("Voer wachtwoord in: ", "encrypted.payload");
+ Program program = new("Enter password: ", "encrypted.payload");
program.ExtractCompressedEncryptedPayload();
}
@@ -28,7 +28,7 @@ class Program(string passwordPrompt, string embeddedResourceName)
return;
}
- // Lees bestandsnaam lengte en bestandsnaam
+ // Read FileName
byte[]? fileNameLengthBytes = new byte[4];
resourceStream.Read(fileNameLengthBytes, 0, fileNameLengthBytes.Length);
int fileNameLength = BitConverter.ToInt32(fileNameLengthBytes, 0);
@@ -36,7 +36,7 @@ class Program(string passwordPrompt, string embeddedResourceName)
resourceStream.Read(fileNameBytes, 0, fileNameLength);
string? fileName = Encoding.UTF8.GetString(fileNameBytes);
- // Lees salt en versleutelde data
+ // Read salt and encrypted data
byte[]? salt = new byte[16];
resourceStream.Read(salt, 0, salt.Length);
@@ -51,6 +51,7 @@ class Program(string passwordPrompt, string embeddedResourceName)
aes.Key = key;
aes.IV = iv;
+ // Decrypt
using MemoryStream? decryptedStream = new();
using (CryptoStream? cs = new(decryptedStream, aes.CreateDecryptor(), CryptoStreamMode.Write))
{
@@ -58,7 +59,7 @@ class Program(string passwordPrompt, string embeddedResourceName)
cs.FlushFinalBlock();
}
- // Decomprimeer
+ // Decompress
byte[]? compressedData = decryptedStream.ToArray();
using MemoryStream? compressedStream = new(compressedData);
using MemoryStream? decompressedStream = new();
@@ -69,9 +70,9 @@ class Program(string passwordPrompt, string embeddedResourceName)
byte[]? decompressed = decompressedStream.ToArray();
- string? outputPath = fileName; // Gebruik originele bestandsnaam
+ string? outputPath = fileName; // Usee original filename
File.WriteAllBytes(outputPath, decompressed);
- Console.WriteLine($"Uitgepakt naar: {outputPath}");
+ Console.WriteLine($"Saved to: {outputPath}");
}
}
\ No newline at end of file
diff --git a/EncryptedPayload/Program.cs b/EncryptedPayload/Program.cs
index f409ff3..76fe672 100644
--- a/EncryptedPayload/Program.cs
+++ b/EncryptedPayload/Program.cs
@@ -6,7 +6,7 @@ class Program(string inputFile, string passwordPrompt, string outputFile)
{
static void Main(string[] args)
{
- Program program = new("input.txt", "Voer wachtwoord in: ", "encrypted.payload");
+ Program program = new("input.txt", "Enter password: ", "encrypted.payload");
program.CreateCompressedEncryptedPayload();
}
@@ -17,11 +17,11 @@ class Program(string inputFile, string passwordPrompt, string outputFile)
if (string.IsNullOrEmpty(password)) return;
byte[]? inputData = File.ReadAllBytes(inputFile);
- string fileName = Path.GetFileName(inputFile); // Haal alleen bestandsnaam + extensie
+ string fileName = Path.GetFileName(inputFile); // only store FileName and extension
byte[]? fileNameBytes = Encoding.UTF8.GetBytes(fileName);
byte[]? fileNameLength = BitConverter.GetBytes(fileNameBytes.Length);
- // Comprimeer
+ // Compress
using MemoryStream? compressedStream = new();
using (GZipStream? gzip = new(compressedStream, CompressionMode.Compress))
{
@@ -29,7 +29,7 @@ class Program(string inputFile, string passwordPrompt, string outputFile)
}
byte[]? compressedData = compressedStream.ToArray();
- // Versleutel
+ // Encrypt
byte[]? salt = new byte[16];
RandomNumberGenerator.Fill(salt);
@@ -42,8 +42,8 @@ class Program(string inputFile, string passwordPrompt, string outputFile)
aes.IV = iv;
using MemoryStream? ms = new();
- ms.Write(fileNameLength, 0, fileNameLength.Length); // Lengte van bestandsnaam
- ms.Write(fileNameBytes, 0, fileNameBytes.Length); // Bestandsnaam
+ ms.Write(fileNameLength, 0, fileNameLength.Length); // FileName Length
+ ms.Write(fileNameBytes, 0, fileNameBytes.Length); // FileName itself
ms.Write(salt, 0, salt.Length); // Salt
using (CryptoStream? cs = new(ms, aes.CreateEncryptor(), CryptoStreamMode.Write))
@@ -53,6 +53,6 @@ class Program(string inputFile, string passwordPrompt, string outputFile)
}
File.WriteAllBytes(outputFile, ms.ToArray());
- Console.WriteLine($"Compressed en encrypted payload opgeslagen in: {outputFile}");
+ Console.WriteLine($"Compressed and encrypted payload saved to: {outputFile}");
}
}