public void TestEncrypt1() { var input = "MORSE CODE"; var decrypted = new MorseAlgorithm().Encrypt(input); var expected = "-- --- .-. ... . / -.-. --- -.. ."; Assert.AreEqual(expected, decrypted); }
/// <summary> /// Encrypts the specified string with specified algorithm. /// </summary> private IHttpActionResult Encrypt(string alg, string str) { if (alg == null) { return(BadRequest("'alg' parameter is not specified.")); } if (str == null) { return(BadRequest("'str' parameter is not specified.")); } alg = alg.Trim(); if (string.Equals(alg, "morse", StringComparison.InvariantCultureIgnoreCase)) { var encrypted = new MorseAlgorithm().Encrypt(str); return(Ok(encrypted)); } else { return(BadRequest($"Unknown cipher algorithm {alg}.")); } }