Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Decompiled with JetBrains decompiler
- // Type: CrackMe.Program
- // Assembly: CrackMe, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
- // MVID: 7588AF36-84AD-43FF-9334-793E1CC1BF11
- // Assembly location: C:\Users\Ian\Downloads\CrackMe.exe
- using System;
- using System.IO;
- namespace CrackMe
- {
- internal class Program
- {
- private static void Main(string[] args)
- {
- if (args.Length != 4)
- {
- Console.WriteLine("Incorrect arguments");
- Console.WriteLine("Usage: CrackMe.exe <input_file> <output_file> <user_pass_phrase> <mode>");
- }
- else
- {
- string path = args[0];
- string outputFile = args[1];
- string str1 = args[2];
- string str2 = args[3];
- if (!File.Exists(path))
- {
- Console.WriteLine("Input file doesn't exist");
- }
- else
- {
- CryptoOperation crypto = new CryptoOperation();
- crypto.FileName = path;
- crypto.UserPassword = str1;
- if (!(str2 == "encrypt"))
- {
- if (str2 == "decrypt")
- {
- Program.Decrypt(crypto, outputFile);
- }
- else
- {
- Console.WriteLine("Incorrect mode");
- Console.WriteLine("Use encrypt or decrypt");
- }
- }
- else
- Program.Encrypt(crypto, outputFile);
- }
- }
- }
- private static void Encrypt(CryptoOperation crypto, string outputFile)
- {
- crypto.ParseFileToEncrypt();
- byte[] buffer = crypto.EncryptFile();
- using (BinaryWriter binaryWriter = new BinaryWriter((Stream) File.Open(outputFile, FileMode.Create)))
- {
- binaryWriter.Write(crypto.IV);
- binaryWriter.Write(buffer);
- }
- Console.WriteLine("That's all.");
- }
- private static void Decrypt(CryptoOperation crypto, string outputFile)
- {
- crypto.ParseFileToDecrypt();
- byte[] buffer = crypto.DecryptFile();
- if (buffer == null)
- return;
- using (BinaryWriter binaryWriter = new BinaryWriter((Stream) File.Open(outputFile, FileMode.Create)))
- binaryWriter.Write(buffer);
- Console.WriteLine("That's all.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement