public void PassWithStrings() { var encoded = Substitution.Encode("12345678901234567890123456789012", "1234567887654321", SBlockTypes.GOST); var decoded = Substitution.Decode("12345678901234567890123456789012", "1234567887654321", SBlockTypes.GOST); Assert.IsNotNull(encoded); Assert.IsNotNull(decoded); Assert.IsNotEmpty(encoded); Assert.IsNotEmpty(decoded); Assert.AreEqual(decoded, encoded); }
public void FailWithNotEqualsSBlocks() { var encoded = Substitution.Encode("12345678901234567890123456789012", "1234567887654321", SBlockTypes.CryptoProB); var decoded = Substitution.Decode("12345678901234567890123456789012", "1234567887654321", SBlockTypes.GOST); Assert.IsNotNull(encoded); Assert.IsNotNull(decoded); Assert.IsNotEmpty(encoded); Assert.IsNotEmpty(decoded); Assert.AreNotEqual(decoded, encoded); }
public void PassWithBytes() { byte[] key = Encoding.UTF8.GetBytes("12345678901234567890123456789012"); byte[] message = Encoding.Default.GetBytes("1234567887654321"); var encoded = Substitution.Encode(key, message, SBlockTypes.GOST); var decoded = Substitution.Decode(key, message, SBlockTypes.GOST); Assert.IsNotNull(encoded); Assert.IsNotNull(decoded); Assert.IsNotEmpty(encoded); Assert.IsNotEmpty(decoded); Assert.AreEqual(decoded, encoded); }
public ActionResult <string> GetDecrypt(string method, string str, string key) { try { if (method == "caesar") { Caesar caesar = new Caesar(); var result = caesar.Decode(str, key); if (result.Item2 == true) { SaveDecryptItems(method, str, key, result.Item1); return(result.Item1); } } else if (method == "railfence") { RailFence railFence = new RailFence(); var result = railFence.Decode(str, key); if (result.Item2 == true) { SaveDecryptItems(method, str, key, result.Item1); return(result.Item1); } } else if (method == "affine") { Affine affine = new Affine(); var result = affine.Decode(str, key); if (result.Item2 == true) { SaveDecryptItems(method, str, key, result.Item1); return(result.Item1); } } else if (method == "substitution") { Substitution substitution = new Substitution(); var result = substitution.Decode(str, key); if (result.Item2 == true) { SaveDecryptItems(method, str, key, result.Item1); return(result.Item1); } } } catch (System.Exception e) { return(e.Message); } return("No such method!"); }