public void EncryptTest() { byte[] original = null; byte[] expected = null; byte[] actual; actual = JhEncrypt.Encrypt(original); Assert.AreEqual(expected, actual); Assert.Inconclusive("验证此测试方法的正确性。"); }
public void EncryptTest2() { string original = string.Empty; string expected = string.Empty; string actual; actual = JhEncrypt.Encrypt(original); Assert.AreEqual(expected, actual); Assert.Inconclusive("验证此测试方法的正确性。"); }
/// <summary> /// 打包数据 /// </summary> /// <param name="t"></param> /// <param name="strKey">加密key</param> /// <returns></returns> public static byte[] PacketData(T t, string strKey) { JsonSerializerSettings setting = new JsonSerializerSettings(); setting.NullValueHandling = NullValueHandling.Ignore; //忽略为NULL的值 byte[] content; string strJson = JsonConvert.SerializeObject(t, setting); //字符串转json:主要是规范 strJson = JhEncrypt.Encrypt(strJson, strKey); //加密:主要是安全 content = SerializeHelper.ConvertToByte(strJson); //序列化:主要是二进制传输效率高 return(content); }