static void TestStringCrypto() { string P = "thisisaplaintext"; string K = "thisisakey"; Console.WriteLine("P: " + P); Console.WriteLine("K: " + K); Console.WriteLine(); // Ayni string'i ayni anahtar ile 20 kere sifrele // Hepsinin sifrelenmis hali farklı ama cozunce ayni string degerini veriyor for (int i = 0; i < 20; i++) { string C1 = P.Encrypt(K); string P1 = C1.Decrypt(K); Console.WriteLine("C{0}: " + C1, i + 1); Console.WriteLine("P{0}: " + P1, i + 1); Console.WriteLine(); } // Empty string icin test string CBos = StringCrypto.Encrypt(string.Empty, string.Empty); string PBos = StringCrypto.Decrypt(CBos, string.Empty); Console.WriteLine("CBos: " + CBos); Console.WriteLine("PBos: " + PBos); Console.WriteLine(); Console.WriteLine("Internal Test: " + StringCrypto.Test().ToString()); }
public void BaseTest() { var cy = new StringCrypto(Convert.ToBase64String("123".ToArrayInByte()), Convert.ToBase64String("321".ToArrayInByte())); var 加密后字符串 = cy.Encrypt("abc"); Console.WriteLine(加密后字符串); var 解密字符串 = cy.Decrypt(加密后字符串); Assert.AreEqual("abc", 解密字符串); }
public void DecryptTest() { string strBase64KEY = string.Empty; // TODO: 初始化为适当的值 string strBase64IV = string.Empty; // TODO: 初始化为适当的值 StringCrypto target = new StringCrypto(strBase64KEY, strBase64IV); // TODO: 初始化为适当的值 string strValue = string.Empty; // TODO: 初始化为适当的值 string expected = string.Empty; // TODO: 初始化为适当的值 string actual; actual = target.Decrypt(strValue); Assert.AreEqual(expected, actual); Assert.Inconclusive("验证此测试方法的正确性。"); }