public override DecodedMessage Create() { ICipher caesar = new CaesarCipher(); string decoded = caesar.Decrypt(text, key); return(new CaesarDecodedMessage(decoded)); }
static void Main(string[] args) { IKeyProvider<int> keyProvider = new ConsoleNumberKeyProvider(); ICryptoProvider<string> cryptoProvider = new CaesarCipher(keyProvider, false); Console.WriteLine("Caesar cipher demonsration"); Console.WriteLine(); try { while (true) { keyProvider.ResetKey(); Console.WriteLine("Enter any text:"); var input = Console.ReadLine(); var encryptedInput = cryptoProvider.Encrypt(input); var decryptedIput = cryptoProvider.Decrypt(encryptedInput); Console.WriteLine(); Console.Write("Ecrypted:"); Console.WriteLine(encryptedInput); Console.Write("Decrypted:"); Console.WriteLine(decryptedIput); Console.WriteLine(); } } catch (Exception ex) { Console.WriteLine(ex.Message); Console.ReadLine(); } }
public void ShouldEncrypt2Correctly(string input, string[] expected) { var cipher = new CaesarCipher(); var result = cipher.Encrypt2(input, 1); result.Should().BeEquivalentTo(expected, opt => opt.WithStrictOrdering()); }
private static void ShowCaesarEncryption() { Console.WriteLine("--*-- Caesar Cipher example --*--"); Console.WriteLine("Type a string to encrypt (or hit Enter to continue with default): "); string inputText = Console.ReadLine(); if (inputText == "") { inputText = plainText; } Console.WriteLine("Enter the key value (numberic)"); string key = Console.ReadLine(); int intKey = 0; if (!Int32.TryParse(key, out intKey)) { intKey = -1; } Console.WriteLine("Encrypted text input with Caesar Cipher by {0} spaces:", intKey); string cipherText = CaesarCipher.Encipher(inputText, intKey); Console.WriteLine(cipherText); Console.Write("\n"); Console.WriteLine("Decrypted Data:"); string t = CaesarCipher.Decipher(cipherText, intKey); Console.WriteLine(t); }
/// <summary> /// Шифр Цезаря /// </summary> public static void CaesarCipherTest() { Console.WriteLine("6. Шифр Цезаря"); Console.WriteLine("Пример работы программы"); cryptogram = "I study at DNU!"; Console.WriteLine("Текст: " + cryptogram); int shift = 2; Console.WriteLine("Длина сдвига алфавита: " + shift); caesarCipher = new CaesarCipher(shift); encryptText = caesarCipher.Encrypt(cryptogram); Console.WriteLine("Зашифрованый текст: " + encryptText); decryptText = caesarCipher.Decrypt(encryptText); Console.WriteLine("Расшифрованый текст: " + decryptText); // Расшифруйте криптограмму (n = 2) Console.WriteLine("\nРасшифруйте криптограмму (n = 2)"); shift = 2; cryptogram = "YGBPGGFBOQTGBUPQYBHQTBDCVVGTBUMKKPI"; Console.WriteLine("Текст: " + cryptogram); Console.WriteLine("Длина сдвига алфавита: " + shift); caesarCipher = new CaesarCipher(shift); decryptText = caesarCipher.Decrypt(cryptogram); Console.WriteLine("Расшифрованый текст: " + decryptText); Console.WriteLine("\n"); }
private void Decrypt_Click(object sender, RoutedEventArgs e) { var cipher = new CaesarCipher(); textbox.Text = cipher.Decrypt(Encrypted_text.Text, key, alfabet); TextLabel.Content = "Decrypted text"; }
public void ShouldDecrypt2Correctly(string expected, string[] parts) { var cipher = new CaesarCipher(); var result = cipher.Decrypt2(parts); result.Should().Be(expected); }
public override EncodedMessage Create() { ICipher caesar = new CaesarCipher(); string encoded = caesar.Encrypt(text, key); return(new CaesarEncodedMessage(encoded)); }
/* * By : Mecit SARIGÜZEL * [email protected] */ static void Main(string[] args) { /* * Uncomment one line which contains the algorithm you need to use */ string input = "merhaba"; IEncryptionAlgorithm algorithm; algorithm = new CaesarCipher(input); // algorithm = new ShiftAlgorithm(input, 5); // algorithm = new DisplacementAlgorithm(input); // algorithm = new PermutationAlgorithm(input, 5, new[] { 4, 1, 5, 2, 3 }); /* * input = "bilgisayarmuhendisligi"; * algorithm = new RouteAlgorithm(input, 5); */ /* * input = "bilgisayarmuhendisligi"; * algorithm = new ZigzagAlgorithm(input, 5); */ /* * input = "afyonkarahisar"; * algorithm = new VigenereCipher(input, "araba"); */ Console.WriteLine($"\n\t\t=> Algorithm Name : {algorithm.Name} <="); Console.WriteLine($"\n\t\t[ Input : {input} ]"); Console.WriteLine($"\n\t\t-> Encryption result : {algorithm.Encrypt()}"); Console.WriteLine($"\t\t-> Decryption result : {algorithm.Decrypt()}\n"); }
public ProductionCipher(CaesarCipher caesarCipher, RotateCipher rotateCipher, XorCipher xorCipher) { this.caesarCipher = caesarCipher; this.rotateCipher = rotateCipher; this.xorCipher = xorCipher; }
public void Scenario_Decrypt_ShiftLessThan26() { String text = "OzqnzxHfjxfwBfxFxxfxxnsfyji"; int s = 5; String decryptedText = CaesarCipher.Decrypt(text, s); Assert.AreEqual(decryptedText, "JuliusCaesarWasAssassinated"); }
public void Scenario_Encrypt_ShiftMoreThan26() { String text = "JuliusCaesarWasAssassinated"; int s = 28; String encryptedText = CaesarCipher.Encrypt(text, s); Assert.AreEqual(encryptedText, "LwnkwuEcguctYcuCuucuukpcvgf"); }
public void TestRot13() { var secret = "OlEdId"; var expected = "ByRqVq"; var actual = CaesarCipher.ShiftCharacters(secret, 13); Assert.Equal(expected, actual); }
public void TestNegativeRot1() { var secret = "OLEDID"; var expected = "NKDCHC"; var actual = CaesarCipher.ShiftCharacters(secret, -1); Assert.Equal(expected, actual); }
static void Main(string[] args) { if (args[0] == null) { Console.WriteLine("No cipher method selected!"); return; } if (args[1] == null) { Console.WriteLine("No action selected!"); return; } Cipher cipher; var cipherType = args[0]; var action = args[1]; switch (cipherType) { case "-c": cipher = new CaesarCipher(); break; case "-a": cipher = new Ciphers.AffineCipher(); break; default: HandleOperationResult(new OperationResult(false, "Unknown cipher type.")); return; } var handler = new OperationHandler(cipher); switch (action) { case "-e": HandleOperationResult(handler.Encrypt()); break; case "-d": HandleOperationResult(handler.Decrypt()); break; case "-j": HandleOperationResult(handler.RunCryptoanalysisWithPlain()); break; case "-k": HandleOperationResult(handler.RunCryptoanalysisWithoutPlain()); break; default: HandleOperationResult(new OperationResult(false, "Unknown action.")); return; } }
static void Main(string[] args) { CaesarCipher caesarCipher = new CaesarCipher(); string s = caesarCipher.Encrypt("Привет, меня зовут Кирилл2432423.", 6); Console.WriteLine(s); Console.WriteLine(caesarCipher.Decrypt(s, 6)); Console.ReadKey(); }
public void Scenario_EncryptDecrypt_SameString() { String text = "InputStringToBeCheckedAfterDecryption"; int s = 5; String encryptedText = CaesarCipher.Encrypt(text, s); String decryptedText = CaesarCipher.Decrypt(encryptedText, s); Assert.AreEqual("InputStringToBeCheckedAfterDecryption", decryptedText); }
protected void Button1_Click(object sender, EventArgs e) { string s = TextBox1.Text.ToString(); int num = Convert.ToInt32(TextBox2.Text); StringBuilder cipher = CaesarCipher.encrypt(s, num); Response.Write("<script>alert('The Encrypted string equals : " + cipher + "')</script>"); TextBox1.Text = ""; TextBox2.Text = ""; }
public static void Main() { string message = "this is just a random message"; CaesarCipher cc = new CaesarCipher(); string encoded = cc.Process(message, 4, true); string decoded = cc.Process(encoded, 4); Console.WriteLine($"Original message: {message}"); Console.WriteLine($"Encoded message: {encoded}"); Console.WriteLine($"Decoded message: {decoded}"); }
public void CaesarEncryptValidInput() { // Arrange CaesarCipher cipher = new CaesarCipher(); string input = "PUSZEK"; string expected = "UZXEJP"; // Act string actual = cipher.Encrypt(input); // Assert Assert.AreEqual(expected, actual); }
public void CaesarDecryptValidInputWithSpace() { // Arrange CaesarCipher cipher = new CaesarCipher(); string input = "ASDF TEST"; string expected = "VNYA OZNO"; // Act string actual = cipher.Decrypt(input); // Assert Assert.AreEqual(expected, actual); }
public void CaesarEncryptValidInputWithSpace() { // Arrange CaesarCipher cipher = new CaesarCipher(); string input = "asdf test"; string expected = "fxik yjxy"; // Act string actual = cipher.Encrypt(input); // Assert Assert.AreEqual(expected, actual); }
public void EncryptionTest_Reverse() { int key = 3; string PlainText = "The quick brown fox jumps over the lazy dogs"; string CipherText = CaesarCipher.CharShift(PlainText, key); System.Console.WriteLine(PlainText); System.Console.WriteLine(CipherText); System.Console.WriteLine(CaesarCipher.CharShift(CipherText, -key)); System.Console.WriteLine(PlainText.ToUpper()); Assert.AreEqual(PlainText.ToUpper(), CaesarCipher.CharShift(CipherText, -key)); }
public void PoundAndEuroSignShouldBeHandled() { string[] input = { "4", "£€£€", "2" }; string output = new CaesarCipher(MoqUtil.SetupRandMock(input)).SolveIt(); Assert.AreEqual("£€£€", output); }
public void BasicAlphabeticalTest() { string[] input = { "3", "abc", "2" }; string output = new CaesarCipher(MoqUtil.SetupRandMock(input)).SolveIt(); Assert.AreEqual("cde", output); }
public void NumbersShouldBeIgnored() { string[] input = { "6", "123456", "2" }; string output = new CaesarCipher(MoqUtil.SetupRandMock(input)).SolveIt(); Assert.AreEqual("123456", output); }
public void MixedPunctuationWithNumbersAndLettersShouldBeHandled() { string[] input = { "12", "123456abc!£$", "2" }; string output = new CaesarCipher(MoqUtil.SetupRandMock(input)).SolveIt(); Assert.AreEqual("123456cde!£$", output); }
// Use this for initialization void Start() { isRearr = false; isCiph = false; ciph = GameObject.Find("CaesarCipher").GetComponent <CaesarCipher>(); scramble = GameObject.Find("WordPuzzle").GetComponent <WordScrambler>(); Rearrange = GameObject.Find("WordPuzzle"); CaesarCiph = GameObject.Find("CaesarCipher"); RearrangeButton = GameObject.Find("Rearrange").GetComponent <Button> (); CipherButton = GameObject.Find("CaesarCiph").GetComponent <Button> (); Rearrange.SetActive(false); CaesarCiph.SetActive(false); }
public void SmallFactorShouldBeHandled() { string[] input = { "3", "XXX", "1" }; string output = new CaesarCipher(MoqUtil.SetupRandMock(input)).SolveIt(); Assert.AreEqual("YYY", output); }
public void WrapAroundShouldBeHandled() { string[] input = { "3", "www", "87" }; string output = new CaesarCipher(MoqUtil.SetupRandMock(input)).SolveIt(); Assert.AreEqual("fff", output); }
public void MixedPunctuationAndLettersShouldBeHandled() { string[] input = { "7", "!^_!qrt", "2" }; string output = new CaesarCipher(MoqUtil.SetupRandMock(input)).SolveIt(); Assert.AreEqual("!^_!stv", output); }
public void TestCleanup() { caesarCipher = null; }
public void TestInitialize() { caesarCipher = new CaesarCipher(); }
static void Main(String[] args) { int n = Convert.ToInt32(Console.ReadLine()); string s = Console.ReadLine(); int k = Convert.ToInt32(Console.ReadLine()); CaesarCipher caesar = new CaesarCipher(k); string decodedStr = caesar.Encode(s); Console.WriteLine(decodedStr); Console.ReadLine(); }