/// <summary> /// Constructor Of Decryptor Class. Init options from the console. /// </summary> /// <param name="options">Decryptor Options</param> public Decryptor(DecryptorOptions options) : this() { Options = options; if (options.UseDatabase) { Options.UseDatabase = InitDB(options.DatabasePath); } }
static void Main(string[] args) { Decryptor decryptor; DecryptorOptions decryptorOptions = new DecryptorOptions(); try { decryptorOptions = ParseCommandLineArgs(args); decryptor = new Decryptor(decryptorOptions); if (decryptorOptions.UsageCommand) { HelpCommand(); goto End; } if (!string.IsNullOrWhiteSpace(decryptorOptions.InputPath)) { // Time watch // var watch = System.Diagnostics.Stopwatch.StartNew(); // Decrypt folders with input path and output path decryptor.DecryptAllFolders(decryptorOptions.InputPath, decryptorOptions.OutputPath); // watch.Stop(); // var elapsedMs = watch.ElapsedMilliseconds; // WriteToConsole("Time: " + elapsedMs); if (decryptorOptions.RemoveFolderAfterDecryption) { WriteToConsole("Removing course in database after decryption." + Environment.NewLine, ConsoleColor.Yellow); foreach (string coursePath in Directory.GetDirectories(decryptorOptions.InputPath, "*", SearchOption.TopDirectoryOnly)) { decryptor.RemoveCourseInDb(coursePath); WriteToConsole("Course " + decryptor.GetFolderName(coursePath) + " has been deleted in database." + Environment.NewLine, ConsoleColor.Yellow); } } } else { WriteToConsole("\t/F\t flag is mandatory. Please you the /HELP flag to more information."); } } catch (Exception exception) { WriteToConsole( "Error occured: " + exception.Message + "\n" + exception.StackTrace + Environment.NewLine, ConsoleColor.Red); WriteToConsole( "Please use\t/HELP\tflag to know more about other commands or contact with the publisher."); } End: WriteToConsole(Environment.NewLine + "Press any key to exit the program..."); Console.ReadKey(); }
private static void RunDecryptorOptions(DecryptorOptions options) { try { var decryptor = new Decryptor(options); decryptor.DecryptCourse(); } catch (Exception exception) { Utils.WriteRedText($"Error occured: {exception.Message}"); } }
private static async Task RunDecryptorOptions(DecryptorOptions options) { try { var decryptor = new Decryptor(options); await decryptor.RunAsync(); } catch (Exception exception) { Utils.WriteRedText($"Error occured: {exception.Message}"); } }
public void TestSingleDecryption() { DecryptorOptions options = new DecryptorOptions { UsageMode = Mode.File, InputPath = "TestFiles\\88067_2195c10678b4f73e34795af641ad1ecc.lynda", OutputPath = "TestFiles\\88067_2195c10678b4f73e34795af641ad1ecc.mp4", RemoveFilesAfterDecryption = false }; Decryptor decryptor = new Decryptor(options); decryptor.InitDecryptor(Utils.ENCRYPTION_KEY); decryptor.Decrypt(options.InputPath, options.OutputPath); FileInfo encryptedFile = new FileInfo(options.InputPath); FileInfo decryptedFile = new FileInfo(options.OutputPath); Assert.AreEqual(encryptedFile.Length, decryptedFile.Length); }
public void TestFileMode() { List <string> args = new List <string>(); args.Add("/F"); args.Add("TestFiles\\88067_2195c10678b4f73e34795af641ad1ecc.lynda"); args.Add("output.mp4"); DecryptorOptions options = new DecryptorOptions(); options = Utils.ParseCommandLineArgs(args.ToArray()); Assert.IsTrue(options.UsageMode == Mode.File); Assert.AreEqual("TestFiles\\88067_2195c10678b4f73e34795af641ad1ecc.lynda", options.InputPath); Assert.AreEqual("output.mp4", options.OutputPath); args.Add("/DB"); options = Utils.ParseCommandLineArgs(args.ToArray()); Assert.IsTrue(options.UseDatabase); Assert.AreEqual(null, options.DatabasePath); args.Add("TestDB\\db_de.sqlite"); options = Utils.ParseCommandLineArgs(args.ToArray()); Assert.AreEqual(args.Last(), options.DatabasePath); args.Add("/RM"); options = Utils.ParseCommandLineArgs(args.ToArray()); Assert.IsTrue(options.RemoveFilesAfterDecryption); args.Add("/OUT"); args.Add("testfolder"); options = Utils.ParseCommandLineArgs(args.ToArray()); Assert.IsTrue(options.UseOutputFolder); Assert.AreEqual(args.Last(), options.OutputFolder); }
public void TestFolderMode() { List <string> args = new List <string>(); args.Add("/D"); args.Add("TestFiles"); DecryptorOptions options = new DecryptorOptions(); options = Utils.ParseCommandLineArgs(args.ToArray()); Assert.IsTrue(options.UsageMode == Mode.Folder); Assert.AreEqual(options.InputPath, "TestFiles"); args.Add("/RM"); options = Utils.ParseCommandLineArgs(args.ToArray()); Assert.IsTrue(options.RemoveFilesAfterDecryption); args.Add("/DB"); options = Utils.ParseCommandLineArgs(args.ToArray()); Assert.IsTrue(options.UseDatabase); Assert.AreEqual(null, options.DatabasePath); args.Add("TestDB\\db_de.sqlite"); options = Utils.ParseCommandLineArgs(args.ToArray()); Assert.AreEqual(args.Last(), options.DatabasePath); args.Add("/OUT"); args.Add("testfolder"); options = Utils.ParseCommandLineArgs(args.ToArray()); Assert.IsTrue(options.UseOutputFolder); Assert.AreEqual(options.OutputFolder, args.Last()); }
public Decryptor(DecryptorOptions options) { this.options = options; decryptor = new DecryptManager(options.OutputPath, options.DatabasePath, options.CoursesPath); }
public Repository(DecryptorOptions options) { context = new PluralSightContext(options); }
public Decryptor(DecryptorOptions options) { repository = new Repository(options); this.options = options; }
public PluralSightContext(DecryptorOptions options) { this.options = options; }