public void Bacon() { BaconCipher cipher = new BaconCipher(); const string plaintext = "HELLO WORLD"; const string ciphertext = "AABBBAABAAABABAABABAABBAB BABAAABBABBAAAAABABAAAABB"; Assert.AreEqual(ciphertext, cipher.Encrypt(plaintext), true); Assert.AreEqual(plaintext, cipher.Decrypt(ciphertext), true); }
public IActionResult BaconDecrypt([FromBody] BaconCipherViewModel viewModel) { BaconCipher cipher = new BaconCipher(); string decrypted = ""; try { decrypted = cipher.Decrypt(viewModel.Message); } catch (Exception) { return(BadRequest(new { Result = false, Message = Text.InvalidCharacter })); } return(Json(decrypted)); }
public IActionResult BaconVisualization([FromBody] BaconCipherViewModel viewModel) { BaconCipher cipher = new BaconCipher(); string[] results = new string[2] { "input", "output" }; string encrypted = ""; string input = viewModel.Message; input = StringHelper.ReplaceWhitespace(input, ""); input = input.ToUpper(); results[0] = input; try { encrypted = cipher.Encrypt(viewModel.Message); results[1] = encrypted; } catch (Exception) { return(BadRequest(new { Result = false, Message = Text.InvalidCharacter })); } return(Json(results)); }