static void Main(string[] args) { string texteClair = null; string key = null; string texteChiffre = null; Console.WriteLine("Quelle phrase voulez-vous encoder :"); texteClair = Console.ReadLine(); Console.WriteLine("Entrez votre clef :"); key = Console.ReadLine(); Vigenere vigenere = new Vigenere(); texteChiffre = vigenere.Encrypt(texteClair, key); Console.WriteLine("\nTexte en claire : " + texteClair); Console.WriteLine("Cléf : " + key + " "); Console.WriteLine("Texte chiffré : " + texteChiffre); texteClair = vigenere.Decrypt(texteChiffre, key); Console.WriteLine("\nTexte chiffré : " + texteChiffre); Console.WriteLine("Cléf : " + key + " "); Console.WriteLine("Texte claire : " + texteClair); Console.Read(); }
public string ResetFileName() { string originalFilename = new Vigenere().full_key_decrypt(this.Name, this.SecureCode); this.Name = originalFilename.Substring(13); return(this.Name); }
public ActionResult DocxEncode(UploadedFile file) { lastKeyFile = file.KeyFile; lastFileName = file.FileName; try { //"application/vnd.openxmlformats-officedocument.wordprocessingml.document" using (MemoryStream ms = new MemoryStream()) { byte[] arr = new byte[file.UploadedFileValue.ContentLength]; file.UploadedFileValue.InputStream.Read(arr, 0, file.UploadedFileValue.ContentLength); ms.Write(arr, 0, arr.Length); string body = Parser.ParseDocx(ms); body = Vigenere.Encode(body, file.KeyFile); byte[] result = Parser.SaveDocx(body); string fName = "Encoded.docx"; if (file.FileName != null) { fName = file.FileName + ".docx"; } return(File(result, "application/docx", fName)); } } catch (Exception e) { lastKeyFile = e.Message; return(Redirect("/Home")); } }
public void IndexDecodeTextTest() { RedirectResult redir = controller.TextDecode(new Text("Привет мир!", "б", "test")) as RedirectResult; result = controller.Index() as ViewResult; Assert.AreEqual(Vigenere.Decode("Привет мир!", "б"), result.ViewBag.TextValue); }
public void Decrypt(string source, string key, string expected) { var crypto = new Vigenere(); string actual = crypto.Dencrypt(source, key); Assert.AreEqual(expected, actual); }
public void Encrypt_NullKeyProvided_ThrowException() { var source = "Hello"; var cipher = new Vigenere(); Assert.Throws(typeof(ArgumentNullException), delegate { cipher.Encrypt(source, null); }); }
public void EncryptBasic() { Vigenere v = new Vigenere("PALIMPSEST", new CipherNet.Common.Alphabet("KRYPTOS")); var encryptedText = v.Encrypt("BETWEENSUBTLESHADINGANDTHEABSENCEOFLIGHTLIESTHENUANCEOFIQLUSION"); Assert.AreEqual("EMUFPHZLRFAXYUSDJKZLDKRNSHGNFIVJYQTQUXQBQVYUVLLTREVJYQTMKYRDMFD", encryptedText); }
public void elegirAlgoritmo(string opcion) { string vigenere = "Vigenere"; string transposicion = "Transposicion"; string codificacionBinaria = "Binario"; string palabraClave = "Palabra Clave"; if (opcion.Equals(vigenere)) { anadirAlgoritmoALista(Vigenere.getVigenere()); } else if (opcion.Equals(transposicion)) { anadirAlgoritmoALista(Transposicion.getTransposicion()); } else if (opcion.Equals(codificacionBinaria)) { anadirAlgoritmoALista(CodificacionBinaria.getCodificacionBinaria()); } else if (opcion.Equals(palabraClave)) { anadirAlgoritmoALista(PalabraClave.getPalabraClave()); } else { anadirTodoAlgoritmo(); } }
static bool HomeworkSection1() { // Start finding key with only known cipher text attack bool successfull = DecryptWithKnownCipherText(); // If known cipher text attack has not been successfull, try known plain text and cipher text attack. if (!successfull) { successfull = DecryptWithKnownPlainAndCipherText(); } if (successfull) { // Decode the cipher text with the found keyword to check whether the found keyword is correct or not. Vigenere vigenere = new Vigenere(); string decodedText = vigenere.Decode(cipherText, keywordText); if (decodedText == plainText) { Console.WriteLine("Cipher text decrypted successfully!"); } } return(successfull); }
public void DecodeWrongLetters() { string text = "Пrи8еТ"; string key = "б"; string result = Vigenere.Decode(text, key); Assert.AreEqual("Оrз8дС", result); }
public void EncodeWrongLetters() { string text = "Пrи8еТ"; string key = "б"; string result = Vigenere.Encode(text, key); Assert.AreEqual("Рrй8ёУ", result); }
public void DecodeUpperLetters() { string text = "ПривеТ"; string key = "б"; string result = Vigenere.Decode(text, key); Assert.AreEqual("ОпзбдС", result); }
public void EncodeUpperLetters() { string text = "ПривеТ"; string key = "б"; string result = Vigenere.Encode(text, key); Assert.AreEqual("РсйгёУ", result); }
public void EncodeLowerLetters() { string text = "привет"; string key = "б"; string result = Vigenere.Encode(text, key); Assert.AreEqual("рсйгёу", result); }
public IActionResult vg_decrypt(Vigenere vg) { vg.decrypted = ""; vg.encrypted = Request.Form["encrypted"]; vg.key = Request.Form["key"]; vg.processText(); return(View("vigenere", vg)); }
public void Encrypt_IncorrectInput_ThrowException() { var source = "Hello!"; var key = "key"; var cipher = new Vigenere(); Assert.Throws(typeof(ArgumentException), delegate { cipher.Encrypt(source, key); }); }
void anadirTodoAlgoritmo() { algoritmos.Clear(); algoritmos.Add(Vigenere.getVigenere()); algoritmos.Add(Transposicion.getTransposicion()); algoritmos.Add(CodificacionBinaria.getCodificacionBinaria()); algoritmos.Add(PalabraClave.getPalabraClave()); }
public void KeyCheckUpper() { string text = "аааааа"; string key = "Абв"; string result = Vigenere.Encode(text, key); Assert.AreEqual("абвабв", result); }
public void DecodeLowerLetters() { string text = "привет"; string key = "б"; string result = Vigenere.Decode(text, key); Assert.AreEqual("опзбдс", result); }
public void DecodeEmpty() { string text = ""; string key = "б"; string result = Vigenere.Decode(text, key); Assert.AreEqual("", result); }
public void DencryptEnumerable(string[] sources, string key, string[] expected) { var crypto = new Vigenere(); string[] actual = crypto.Dencrypt(sources, key).ToArray(); Assert.AreEqual(expected, actual); }
public void Decode_OnlyLatinAlphabet() // Проверка зашифровки файла содержащего только латинский алфавит { string input = File.ReadAllText(@"../../testFiles/Decoding/Test3.txt", Encoding.UTF8); string expectedResult = File.ReadAllText(@"../../testFiles/Encoding/Test3.txt", Encoding.Default); input = Vigenere.Decode(input, "скорпион"); Assert.AreEqual(input, expectedResult); }
private void VigenereDecode(object sender, RoutedEventArgs e) { Vigenere vigenere = new Vigenere(); string value = VigenereDecodeInput.Text; string key = VigenereDecodeKeyInput.Text; VigenereDecodeOutput.Text = vigenere.Decrypt(value, key); }
public void Decode_OnlyNumbers() // Проверка зашифровки файла содержащего только цифры { string input = File.ReadAllText(@"../../testFiles/Decoding/Test4.txt", Encoding.UTF8); string expectedResult = File.ReadAllText(@"../../testFiles/Encoding/Test4.txt", Encoding.Default); input = Vigenere.Decode(input, "скорпион"); Assert.AreEqual(input, expectedResult); }
public void Decode_CyrilicLettersAndNumbers() // Проверка зашифровки файла содержащего цифры, буквы и пробельные символы { string input = File.ReadAllText(@"../../testFiles/Decoding/Test2.txt", Encoding.UTF8); string expectedResult = File.ReadAllText(@"../../testFiles/Encoding/Test2.txt", Encoding.Default); input = Vigenere.Decode(input, "скорпион"); Assert.AreEqual(input, expectedResult); }
public void Decode_OnlyCyrillicLetters() // Проверка шифрования файла содержащего только буквы и пробельные символы { string input = File.ReadAllText(@"../../testFiles/Decoding/Test1.txt", Encoding.UTF8); string expectedResult = File.ReadAllText(@"../../testFiles/Encoding/Test1.txt", Encoding.Default); input = Vigenere.Decode(input, "скорпион"); Assert.AreEqual(input, expectedResult); }
public void Encrypt_EmptyInput_EmptyOutput() { var source = ""; var key = "key"; var cipher = new Vigenere(); var encrypted = cipher.Encrypt(source, key); Assert.IsEmpty(encrypted); }
public void TestEncrypt() { IEnumerable <string> source = Program.Preprocess("ALPHA"); string key = "OMEGA"; string expected = "OXTNA"; string actual = Vigenere.Encrypt(source, key).FirstOrDefault(); Assert.AreEqual(expected, actual); }
private void chiffrerBtn_Click(object sender, EventArgs e) { if (textBox1.TextLength != 0 || textBox2.TextLength != 0) { Vigenere vigenere = new Vigenere(); textBox3.Text = vigenere.Encrypt((textBox1.Text), textBox2.Text); chiffrerBtn.Enabled = false; } }
public void TestDecrypt() { IEnumerable <string> encrypt = Program.Preprocess("ALPHA"); string key = "NU"; string expected = "OXTCO"; string actual = Vigenere.Decrypt(encrypt, key).FirstOrDefault(); Assert.AreNotEqual(expected, actual); }