public void LongVigenereReturnsExact() { string key = "tESt KeY!"; string message = "Can you READ this 100%?!"; LongVigenere lv = new LongVigenere(key); string lvE = lv.Encipher(message); string lvD = lv.Decipher(lvE); Assert.AreEqual(message, lvD); }
public void MultilayerReturnsExact() { string key = "tESt KeY!"; string message = "Can you READ this 100%?!"; LongVigenere lv = new LongVigenere(key); TranspositionMatrix tm = new TranspositionMatrix(key); ReverseVigenere rv = new ReverseVigenere(key); string lvE = lv.Encipher(message); string tmE = tm.Encipher(lvE); string rvE = rv.Encipher(tmE); string rvD = rv.Decipher(rvE); string tmD = tm.Decipher(rvD); string lvD = lv.Decipher(tmD); Assert.AreEqual(message, lvD); }
public bool Encipher() { bool fileCreated = false; LongVigenere lv = new LongVigenere(Key); TranspositionMatrix tm = new TranspositionMatrix(Key); ReverseVigenere rv = new ReverseVigenere(Key); try { string fileName = Path.GetFileName(FullPath); string fileNameNoExt = Path.GetFileNameWithoutExtension(fileName); string fileExt = Path.GetExtension(fileName); string fileDir = FullPath.Substring(0, FullPath.Length - fileName.Length); string createFile = fileNameNoExt + "MLC" + fileExt; string createFull = Path.Combine(fileDir, createFile); using (StreamReader sr = new StreamReader(FullPath)) { while (!sr.EndOfStream) { using (StreamWriter sw = new StreamWriter(createFull, true)) { string lvE = lv.Encipher(sr.ReadLine()); string tmE = tm.Encipher(lvE); string rvE = rv.Encipher(tmE); sw.WriteLine(rvE); } } } if (Path.IsPathFullyQualified(createFull)) { fileCreated = true; } File.Move(createFull, FullPath, true); } catch (Exception e) { Console.WriteLine("Invalid input for file path..."); } return(fileCreated); }